From:             mlemos at acm dot org
Operating system: 
PHP version:      4CVS-2003-11-29 (stable)
PHP Bug Type:     Filesystem function related
Bug description:  flock does not force wouldblock argument to be passed by reference

Description:
------------
When present, the wouldblock argument should be a reference to a variable
in which it will return whether it would block if attempted to lock the
file in non-blocking mode.

However, since the argument is not forced to be a reference, it will only
work if you pass an explicit reference to the argument, leading to the
usual warnings.

Changing flock function entry in ext/standard/basic_functions.c like this
fixes the problem:

PHP_FE(flock,third_arg_force_ref)


Reproduce code:
---------------
<?php
        if(!($file=(fopen("testfile","w")))) die("could not open file");
        if(flock($file,6,$wouldblock))
                echo "could lock ",serialize($wouldblock),"\n";
        else
                echo "failed lock\n";
        fclose($file);
?>


Expected result:
----------------
could lock i:0;

Actual result:
--------------
could lock N;

-- 
Edit bug report at http://bugs.php.net/?id=26467&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26467&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26467&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26467&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26467&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26467&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26467&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26467&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26467&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26467&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26467&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26467&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26467&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26467&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26467&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26467&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26467&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26467&r=float

Reply via email to