Bug #54453 [Com]: LOCK_NB works with LOCK_SH when file locked with LOCK_EX ONLY

From: Date: Wed, 27 Mar 2013 21:09:32 +0000
Subject: Bug #54453 [Com]: LOCK_NB works with LOCK_SH when file locked with LOCK_EX ONLY
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-178159@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54453&edit=1 ID: 54453 Comment by: oxygenus at gmail dot com Reported by: teamerx at gmail dot com Summary: LOCK_NB works with LOCK_SH when file locked with LOCK_EX ONLY Status: Open Type: Bug Package: Filesystem function related Operating System: Windows XP Centos Ubuntu (latest PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: Perhaps the method of running the PHP script should be mentioned. If this is not reproducible in CLI mode, then I think something else was at fault, not PHP. http://stackoverflow.com/a/9827159/584490 Previous Comments: ------------------------------------------------------------------------ [2011-04-02 18:42:35] teamerx at gmail dot com Description: ------------ LOCK_NB works with LOCK_SH when file locked with LOCK_EX ONLY LOCK_NB doe NOT work with LOCK_SH if file is locked with LOCK_SH LOCK_NB works with LOCK_EX when file locked with LOCK_SH ONLY LOCK_NB doe NOT work with LOCK_EX if file is locked with LOCK_EX preferred output : LOCK_NB should work with LOCK_SH or LOCK_EX no matter what lock type the file is locked with Test script: --------------- code 1: $x = fopen("flocktest.txt", "a"); if (flock($x, LOCK_SH|LOCK_EX|LOCK_NB)) { print "No problems, I got the lock, now I'm going to sit on it."; @fwrite($x, 'ddd'); sleep(3); } else { print "Didn't quite get the lock. Quitting now. Good night."; } fclose($x); code 2 : $x = fopen("flocktest.txt", "rb"); if ($x){ if (flock($x, LOCK_SH|LOCK_NB)) { print "No problems, I got the lock, now I'm going to sit on it."; @fwrite($fp, 'ddd'); sleep(3); } else { print "Didn't quite get the lock. Quitting now. Good night."; } fclose($x); } if running code 1 then code 1 , lock NB is not working , if running code 1 then code 2 , lock_nb works if running code 2 then code 2 , lock_nb does not work , if running code 2 then code 1 lock nb works . ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54453&edit=1

« previous php.bugs (#178159) next »