All,
One of our customers is running a VFP COM application with 12 instances on a quad-dual-core server.
We're starting to see errors like this:
LINE:1677 ERROR NO:1718 MESSAGE:File
c:\docume~1\clinsu~1\locals~1\temp\0000duzd003g.tmp is read-only.
Line 1677 is a SQL Select statement against an existing VFP cursor into another cursor. We're assuming that 0000duz003g.tmp is the tmp filename allocated internally by VFP for the result. Certainly it's not something we're creating ourselves.
If this is correct, then we're expecting that every so often server instances are able to perform selects at precisely the same time, generating the same supposedly unique tmp filename with only one instance able to save its resultset into that file.
The only way we can see to fix this is for each instance to use its own temp folder.
We know that in VFP the tmpfiles location can be set in config.fpw, but changing that still leaves us with the same temp folder for all the server instances under COM. We are told that you can also set TMPFILES if you add a "COMMAND = Do startup.prg" as the last line in your config.fpw and set TMPFILES in the prg. However, we have found that setting the value of TMPFILES in a startup.prg is ineffective.
Hopefully somebody can tell us how to set tmpfiles uniquely for each instance or otherwise how to avoid this error which is catastrophic. FWIW we experimented with the code below which (despite having minimal trapping) certainly can create a unique folder for each instance but cannot assign it to TMPFILES.
*----startup.prg
*----this prg creates a unique folder in the server's temp folder
*----to avoid filename contentions in a multi-processor server running multiple instances.
public pcUniqueTempPath
local llNotDone
llNotDone=.t.
*---loop until unique folder created successfully...
DO WHILE m.llNotDone
llnotdone=.f.
pcUniqueTempPath=ADDBS(GETENV("TEMP"))+SYS(2015)
*---using getenv() in case sys(2023) not yet available at this point...
TRY
md (m.pcUniqueTempPath) &&if we can create the folder it must be unique...
CATCH
llNotDone=.t. &&nope, somebody else got in first... so try again...
ENDTRY
ENDDO
*---Public variables are said to be naughty but in this case
*---the application object does not yet exist so
*---pcUniqueTempPath is public to allow cleanup before exit
TMPFILES = (pcUniqueTempPath) *---is the above line wrong?