From: Ilia Alshanetsky Date: Fri, 10 Oct 2003 01:38:02 +0000 (+0000) Subject: Fixed bug #25814 (Make flock() return correct value when 3rd argument is X-Git-Tag: php-4.3.4RC2~30 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a1bfae434811b9794485faabd0dba52330cb2b4;p=php Fixed bug #25814 (Make flock() return correct value when 3rd argument is used). # This bug is 4.3.X specific, no need to MFB into 5.X tree. --- diff --git a/NEWS b/NEWS index 76bb11eab3..e63b1ef573 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ PHP 4 NEWS ?? Oct 2003, Version 4.3.4RC2 - Fixed multibyte regex engine to properly handle ".*" pattern under POSIX compatible mode. (K.Kosako , Moriyoshi) +- Fixed bug #25814 (Make flock() return correct value when 3rd argument is + used). (Ilia) - Fixed bug #25780 (ext/session: invalid "session.cookie_lifetime" makes session_start() to crash in win32). (Jani) - Fixed bug #25770 (Segfault with PHP and bison 1.875). (eggert@gnu.org, Marcus) diff --git a/ext/standard/file.c b/ext/standard/file.c index 8470e5c409..27231b3aec 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -226,7 +226,7 @@ static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN }; PHP_FUNCTION(flock) { zval **arg1, **arg2, **arg3; - int fd, act, ret, arg_count = ZEND_NUM_ARGS(); + int fd, act, arg_count = ZEND_NUM_ARGS(); php_stream *stream; if (arg_count < 2 || arg_count > 3 || zend_get_parameters_ex(arg_count, &arg1, &arg2, &arg3) == FAILURE) { @@ -250,11 +250,12 @@ PHP_FUNCTION(flock) /* flock_values contains all possible actions if (arg2 & 4) we won't block on the lock */ act = flock_values[act - 1] | (Z_LVAL_PP(arg2) & 4 ? LOCK_NB : 0); - if ((ret=flock(fd, act)) == -1) { - RETURN_FALSE; - } - if(ret == -1 && errno == EWOULDBLOCK && arg_count == 3) { - ZVAL_LONG(*arg3, 1); + if (flock(fd, act)) { + if (errno == EWOULDBLOCK && arg_count == 3) { + ZVAL_LONG(*arg3, 1); + } else { + RETURN_FALSE; + } } RETURN_TRUE; }