From:
Operating system: Windows XP Centos Ubuntu (latest
PHP version: 5.3.6
Package: Output Control
Bug Type: Bug
Bug description:LOCK_NB works with LOCK_SH when file locked with LOCK_EX ONLY
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 bug report at http://bugs.php.net/bug.php?id=54453&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54453&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54453&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54453&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54453&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54453&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54453&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54453&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54453&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54453&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54453&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54453&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54453&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54453&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54453&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54453&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54453&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54453&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54453&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54453&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54453&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54453&r=mysqlcfg