note 25322 deleted from function.flock by didou

From: Date: Fri, 03 Oct 2003 16:41:41 +0000
Subject: note 25322 deleted from function.flock by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57761@lists.php.net to get a copy of this message
Note Submitter: ---- 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.

« previous php.notes (#57761) next »