From:             mike at aqua-helix dot com
Operating system: Linux RedHat 7.3
PHP version:      4.3.4RC1
PHP Bug Type:     Filesystem function related
Bug description:  Incorrect flock return

Description:
------------
>From documentation about 'flock':
The optional third argument is set to TRUE if the lock would block
(EWOULDBLOCK errno condition)

Actualy third argument will never set to true due to error in
implementation. Let see the code (line 253 in 'file.c'):

        if ((ret=flock(fd, act)) == -1) {
                RETURN_FALSE;
        }
        if(ret == -1 && errno == EWOULDBLOCK && arg_count == 3) {
                ZVAL_LONG(*arg3, 1);
        }

The second 'if' will never act as if ret==1 function immediately returns
false in the first 'if'

Here is my version:

        if ((ret=flock(fd, act)) == -1) {
         if( errno == EWOULDBLOCK && arg_count == 3)
           ZVAL_LONG(arg3, 1);

         RETURN_FALSE;
        }




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

Reply via email to