]> granicus.if.org Git - php/commitdiff
Fixed bug #31363 (broken non-blocking flock()).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 6 Apr 2005 13:57:30 +0000 (13:57 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 6 Apr 2005 13:57:30 +0000 (13:57 +0000)
# Patch by ian at snork dot net

ext/standard/file.c
main/streams/plain_wrapper.c

index 5b98c050adefa309892c01e35fa4a4842ae72213..7ffc1c33be8129dda18a223ab49e60b14271eecb 100644 (file)
@@ -339,13 +339,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 baa4c9508788ef60cf9b1507930c72b0dfe8a995..ad362cf45fced498a0f929c62d1e05c463a104b0 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 {