php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39138 LOCK_NB for flock() does not work
Submitted: 2006-10-12 14:19 UTC Modified: 2006-10-22 01:00 UTC
Votes:13
Avg. Score:4.8 ± 0.6
Reproduced:12 of 12 (100.0%)
Same Version:3 (25.0%)
Same OS:4 (33.3%)
From: php at koterov dot ru Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.1.6 OS: Windows, Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at koterov dot ru
New email:
PHP Version: OS:

 

 [2006-10-12 14:19 UTC] php at koterov dot ru
Description:
------------
<?php
@session_write_close(); // be on the safe side
$f = fopen('/tmp/f.lck', 'a+');
var_dump(flock($f, LOCK_EX | LOCK_NB, $w));
var_dump($w);
sleep(5);
?>

When I run this script concurrently, all results are same: "bool(true) int(0)". Seems LOCK_NB simply ignored.

P.S.
There is a lot of same bugs (e.g., http://bugs.php.net/bug.php?id=31363 etc.), but they are closed or outdated.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-12 14:44 UTC] tony2001@php.net
Not reproducible on Linux.
 [2006-10-13 06:47 UTC] php at koterov dot ru
Ah, on Linux bug is reproducible at version 5.1.1. Sorry, I do not have more recent test machine. On Windows - I've tested 5.1.6, bug is reproducible.
 [2006-10-13 08:34 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-10-13 13:38 UTC] php at koterov dot ru
PHP 5.2.0RC6-dev (cli) (built: Oct 13 2006 12:22:44)

Bug is reproducible.
 [2006-10-13 13:43 UTC] tony2001@php.net
What kind of Server API do you use and is your web-server threaded or not?
Where can I see the results? (as I'm unable to reproduce it locally)
 [2006-10-13 14:12 UTC] php at koterov dot ru
Thanks for detailed testing.

Server version: Apache/2.0.54
Server built:   Apr 16 2005 14:25:31
Windows XP, NTFS.

I don't know if my server threaded or not; where could I see that?

With command-line php.exe effect is NOT quite reproducible: first process prints "bool(true) int(0)", second - "bool(false) int(0)". (Note that in both cases we have 0 in $w; is it proper or not?)

One time I've got in additional a message: "Failed to start up concurrent users module!" with php.exe, but cannot reproduce this message again now.
 [2006-10-13 14:20 UTC] tony2001@php.net
Wait, so did you try the snapshot on Linux?
Or are you talking only of Windows now?
 [2006-10-13 19:06 UTC] php at koterov dot ru
I cannot try snapshot on Linux - I have no machine for experiments. And you said that Linux has no problem in new version.

Now we are talking about Windows only.
 [2006-10-14 13:09 UTC] tony2001@php.net
Where can I see the results? (as I'm unable to reproduce it locally)
 [2006-10-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-05-28 10:50 UTC] bugreporter at sigproc dot de
Hi,

problem might be just due to unclear documentation on how to apply LOCK_NB. The current flock docu says one should "add LOCK_NB to $operation" (i.e. to the second parameter of the function).

A comment on the docu page wants to assure us that neither of the following will work (administrator at proxy-list dot org, 30-Apr-2007 08:30)

<?php
flock($fp, LOCK_EX and LOCK_SH); 
flock($fp, LOCK_EX or LOCK_SH);  
flock($fp, LOCK_EX + LOCK_SH);
?>

(Rather separate flock calls should be used.)

So question to the PHP devs: what is the right way to do it?

Cheers
 [2010-01-14 14:21 UTC] sp at vovochka dot org dot ua
Guys!
Are you going to fix this bug. It is more than 3 years old! It is reproducable on NTFS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC