There are reliable and portable ways to prevent such race conditions easily from Perl. Unfortunately, IPC::DirQueue seems disappointingly naive on this point:
# now, we want to try to avoid 2 or 3 dequeuers removing # the lockfile simultaneously, as that could cause this race: # # dqproc1: [checks file] [unlinks] [starts work] # dqproc2: [checks file] [unlinks] # # ie. the second process unlinks the first process' brand-new # lockfile! # # to avoid this, use a random "fudge" on the timeout, so # that dqproc2 will wait for possibly much longer than # dqproc1 before it decides to unlink it. # # this isn't perfect. TODO: is there a "rename this fd" syscall # accessible from perl?
- tye
In reply to Re: Problems using file based queues on windows (race)
by tye
in thread Problems using file based queues on windows
by joe425
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |