Posted by Andy Jeffries on 05/05/06 11:01
On Thu, 04 May 2006 18:51:28 -0400, Bob_M (remove X for email) wrote:
> Why not try "flock"ing the file(s). YOUR process will wait for the
> other (owner) task to release it before continuing.
Errr, because of the warnings on the flock manual page:
flock() will not work on NFS and many other networked file systems. Check
your operating system documentation for more details.
On some operating systems flock() is implemented at the process level.
When using a multithreaded server API like ISAPI you may not be able to
rely on flock() to protect files against other PHP scripts running in
parallel threads of the same server instance!
flock() is not supported on antiquated filesystems like FAT and its
derivates and will therefore always return FALSE under this environments
(this is especially true for Windows 98 users).
It's not to say it won't work in his situation nor that it wouldn't be a
better solution than the one he's using, but there are other ways.
When studying for the ZCE I seem to remember either the study guide or one
of the practice exams saying to use mkdir for locks as it's a guaranteed
atomic operation and returns true/false for completion.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos
[Back to original message]
|