]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #31363 (broken non-blocking flock()).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 6 Apr 2005 13:59:48 +0000 (13:59 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 6 Apr 2005 13:59:48 +0000 (13:59 +0000)
NEWS
ext/standard/file.c
main/streams/plain_wrapper.c

diff --git a/NEWS b/NEWS
index 739545f619a695de0fcaaff2cfd21af915cdb728..0d1102fa3dc7eb70fcecb86b3386a8b269c149df 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PHP                                                                        NEWS
 - Fixed bug #32491 (File upload error - unable to create a temporary file).
   (Uwe Schindler)
 - Fixed bug #32282 (Segfault in mysqli_fetch_array on 64-bit) (Georg).
+- Fixed bug #31363 (broken non-blocking flock()). ian at snork dot net
 - Fixed bug #28839 (SIGSEGV in interactive mode (php -a)).
   (kameshj at fastmail dot fm)
 
index 6ef83af5e8f1b3a9336e74f26d21db6b3148b85f..0a3998fb3539d3cfd0b317182346a7b925587126 100644 (file)
@@ -275,13 +275,13 @@ PHP_FUNCTION(flock)
 
        /* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
        act = flock_values[act - 1] | (operation & 4 ? LOCK_NB : 0);
-       if (!php_stream_lock(stream, act)) {
+       if (php_stream_lock(stream, act)) {
                if (operation && errno == EWOULDBLOCK && arg3 && PZVAL_IS_REF(arg3)) {
                        Z_LVAL_P(arg3) = 1;
                }
-               RETURN_TRUE;
+               RETURN_FALSE;
        }
-       RETURN_FALSE;
+       RETURN_TRUE;
 }
 
 /* }}} */
index 28e41a26618d144986a8bf3dd705806cd4ac7107..041b36b40cc11dbc0e79c3cd1cce29cd8e977f38 100644 (file)
@@ -578,7 +578,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
                                return 0;
                        }
 
-                       if (!flock(fd, value) || (errno == EWOULDBLOCK && value & LOCK_NB)) {
+                       if (!flock(fd, value)) {
                                data->lock_flag = value;
                                return 0;
                        } else {