]> granicus.if.org Git - php/commitdiff
Fixed bug #25814 (Make flock() return correct value when 3rd argument is
authorIlia Alshanetsky <iliaa@php.net>
Fri, 10 Oct 2003 01:38:02 +0000 (01:38 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 10 Oct 2003 01:38:02 +0000 (01:38 +0000)
used).

# This bug is 4.3.X specific, no need to MFB into 5.X tree.

NEWS
ext/standard/file.c

diff --git a/NEWS b/NEWS
index 76bb11eab332814aa0ef961c73e7431ca289b6f4..e63b1ef573108a706221e9675d6349bc0527a962 100644 (file)
--- 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 <kosako at sofnec.co.jp>, 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)
index 8470e5c409dd5d3c4d0411cac772e7e9150e195d..27231b3aec1e2d0a57e2e4191eeecdfab6952988 100644 (file)
@@ -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;
 }