note 45897 added to function.flock
| From: | chuck at osu1 dot php dot net | Date: | Wed, 22 Sep 2004 20:15:57 +0000 |
| Subject: | note 45897 added to function.flock | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77210@lists.php.net to get a copy of this message | ||
Creating lock files and testing for their existence is absolutely wrong, NFS or not. The only file
operations that are guaranteed to be atomic are mkdir() and symlink(). And those aren't atomic
over NFS (or other network filesystems) either.
Short answer: create lock directories, not files. Don't stat the directory to test, simply try
to create it and see if it fails. And all locking bets are always off with NFS.
----
Manual Page -- http://www.php.net/manual/en/function.flock.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45897
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45897&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45897&report=yes
Search -- http://master.php.net/manage/user-notes.php