php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25814 Incorrect flock return
Submitted: 2003-10-09 19:13 UTC Modified: 2003-10-09 21:35 UTC
From: mike at aqua-helix dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.4RC1 OS: Linux RedHat 7.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
4 + 12 = ?
Subscribe to this entry?

 
 [2003-10-09 19:13 UTC] mike at aqua-helix dot com
Description:
------------
From documentation about 'flock':
The optional third argument is set to TRUE if the lock would block (EWOULDBLOCK errno condition)

Actualy third argument will never set to true due to error in implementation. Let see the code (line 253 in 'file.c'):

	if ((ret=flock(fd, act)) == -1) {
		RETURN_FALSE;
	}
	if(ret == -1 && errno == EWOULDBLOCK && arg_count == 3) {
		ZVAL_LONG(*arg3, 1);
	}

The second 'if' will never act as if ret==1 function immediately returns false in the first 'if'

Here is my version:

        if ((ret=flock(fd, act)) == -1) {
         if( errno == EWOULDBLOCK && arg_count == 3)
           ZVAL_LONG(arg3, 1);

         RETURN_FALSE;
        }




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-09 21:35 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 13:01:29 2024 UTC