ID:               27256
 Updated by:       [EMAIL PROTECTED]
 Reported By:      dmitry at koteroff dot ru
 Status:           Analyzed
 Bug Type:         Documentation problem
 Operating System: Windows NT, 2000, XP, 2003
 PHP Version:      4.3.4
 New Comment:

There is no advisory locking, only mandatory locking.


Previous Comments:
------------------------------------------------------------------------

[2004-02-14 19:34:10] dmitry at koteroff dot ru

Opa. 



But why? If I'm not very wrong, Windows has its own advisory locking
API. Why is it not used?



P.S.

I have forgot to say: this behavour is related to all versions op PHP:
php4 and php5 too.

------------------------------------------------------------------------

[2004-02-14 18:56:32] [EMAIL PROTECTED]

flock() is mandatory under winNT and it's derivatives.  

This is a documentation bug.

------------------------------------------------------------------------

[2004-02-14 18:48:05] dmitry at koteroff dot ru

Description:
------------
This code does not work on Windows:

 

<?

$f1 = fopen("/tmp/a", "a+b");

flock($f1, LOCK_SH);

$f2 = fopen("/tmp/a", "r+b");

fwrite($f2, "test");

?>

 

It creates zero-length file. On Linux everything is OK.

 

If I delete flock() or call flock($f1, LOCK_UN) just after first
flock(), all works correctly.



Flock() is ADVISORY lock, but it works as mandatory lock. Bad luck.

Reproduce code:
---------------
$f1 = fopen("/tmp/a", "a+b");

flock($f1, LOCK_SH);

$f2 = fopen("/tmp/a", "r+b");

fwrite($f2, "test");



Expected result:
----------------
Create non-empty file.

Actual result:
--------------
Creates empty file.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27256&edit=1

Reply via email to