Bug #65272 [Com]: flock() documentation says LOCK_NB is not available on Windows, although it is
| From: | benjamin dot morel at gmail dot com | Date: | Mon, 02 Feb 2015 16:43:58 +0000 |
| Subject: | Bug #65272 [Com]: flock() documentation says LOCK_NB is not available on Windows, although it is | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11912@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65272&edit=1
ID: 65272
Comment by: benjamin dot morel at gmail dot com
Reported by: benjamin dot morel at gmail dot com
Summary: flock() documentation says LOCK_NB is not available
on Windows, although it is
Status: Closed
Type: Bug
Package: Documentation problem
Operating System: N/A
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
@rdlowrey Who should update the documentation?
Previous Comments:
------------------------------------------------------------------------
[2015-02-02 16:38:40] rdlowrey@php.net
This is a documentation bug, but it's also a problem in the actual implementation in windows
environments. The error constant used to determine the value of $wouldblock is different in windows
than other environments. This issue has been corrected in 5.5 and up.
The implementation should now be consistent across all platforms and the documentation should be
updated appropriately.
------------------------------------------------------------------------
[2015-02-02 16:31:46] rdlowrey@php.net
Automatic comment on behalf of rdlowrey
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f2f467bd9609f5fad2491a4718380fadaa449470
Log: Fixed bug #65272: correctly set flock() out param in windows
------------------------------------------------------------------------
[2015-02-02 16:31:23] rdlowrey@php.net
Automatic comment on behalf of rdlowrey
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f2f467bd9609f5fad2491a4718380fadaa449470
Log: Fixed bug #65272: correctly set flock() out param in windows
------------------------------------------------------------------------
[2015-02-02 16:31:02] rdlowrey@php.net
Automatic comment on behalf of rdlowrey
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f2f467bd9609f5fad2491a4718380fadaa449470
Log: Fixed bug #65272: correctly set flock() out param in windows
------------------------------------------------------------------------
[2013-07-16 15:09:10] benjamin dot morel at gmail dot com
Description:
------------
The flock() documentation:
http://php.net/manual/en/function.flock.php
Says:
It is also possible to add LOCK_NB as a bitmask to one of the above operations
if you don't want flock() to block while locking. (not supported on Windows)
In my tests on Windows 7 x64, it does work. But what is true is that the failed
flock() does not set &$wouldblock to 1.
Please see the test script below.
Both scripts must be run at the same time in PHP interactive mode or with a
sleep() to avoid the lock being released automatically.
It would be interesting to test this behaviour on other versions of Windows
(this might not be applicable to all of them), and update the documentation
accordingly. Non-blocking locks are a really useful feature, and it would be
nice to document this properly for Windows users.
Test script:
---------------
Script 1
--------
$f = fopen('file.txt', 'w');
var_export(flock($f, LOCK_EX | LOCK_NB, $wouldblock)); // true
var_export($wouldblock); // 0
Script 2
--------
$f = fopen('file.txt', 'w');
var_export(flock($f, LOCK_EX | LOCK_NB, $wouldblock)); // false
var_export($wouldblock); // 0 (1 on Linux)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65272&edit=1