in reply to CGI filename race
Because your check for the existence of the next file and the updating of the next number to use are not a single atomic action you've created the classic example of a race condition between your multiple processes. You want to look at either perldoc -q lock (in order to lock the history file, but remember you still would need to test for file existence while you have the history locked), or the discussion of the O_EXCL flag to sysopen in perlopentut (which would let the OS do the test-or-create in one atomic step). Or more preferably, read them both :).
|
|---|