note 25322 added to function.flock
| From: | php-general at lists dot php dot net | Date: | Thu, 19 Sep 2002 15:39:45 +0000 |
| Subject: | note 25322 added to function.flock | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-36961@lists.php.net to get a copy of this message | ||
About LOCK_NB
The document on the LOCK_NB flag isn't exactly thorough. I decided to experiment with it a bit
anf this is what I've been able to assertain as to it's function.
The default behaviour for flock is that if it can't aquire a lock on a file pointer, it will
wait until the other process has finished with the file and reliquinahed it's lock and it is
then able to retain one itself. If this doesn't happen, the script will timeout.
If you set the LOCK_NB flag then flock will not wait if it cannot get a lock immideately and will
exit, returning false. You will have to handle the error yourself if you do this but it will
prevent the timeouts that normally occur if you're running a script that tries to lock a file
that's already been locked and for which the lock won't be released any time soon.
--
http://www.php.net/manual/en/function.flock.php
http://master.php.net/manage/user-notes.php?action=edit+25322
http://master.php.net/manage/user-notes.php?action=delete+25322
http://master.php.net/manage/user-notes.php?action=reject+25322