From: Ilia Alshanetsky Date: Wed, 6 Apr 2005 13:59:48 +0000 (+0000) Subject: MFH: Fixed bug #31363 (broken non-blocking flock()). X-Git-Tag: php-5.0.5RC1~478 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a8e47ca98b62b739f416336f42c54068b054513;p=php MFH: Fixed bug #31363 (broken non-blocking flock()). --- diff --git a/NEWS b/NEWS index 739545f619..0d1102fa3d 100644 --- 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) diff --git a/ext/standard/file.c b/ext/standard/file.c index 6ef83af5e8..0a3998fb35 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -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; } /* }}} */ diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 28e41a2661..041b36b40c 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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 {