I have a CGI Perl script that updates a data file when a user submits a web form. The script uses flock to exclusively lock a secondary file to prevent the data file from being updated by more than one user at a time. I believe this has worked well for some time now.
However, I'm beginning to suspect that occasionally (maybe when the web server is busy) the flock call fails.
Unfortunately, I am not trapping for an error condition each time I call flock because I test for the capability at the beginning of the script. I will soon change this to always test for failure. Then I will know for sure if it ever fails.
In the meantime, reading through the documentation for flock, the only reason I can see for flock to fail is if the operating system doesn't support file locking. Otherwise, unless you tell it not to, it waits indefinitely.
Are there occasions where flock will not wait indefinitely but will instead fail?
Any help would be greatly appreciated.
Richard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |