|  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
 [2003-10-09 19:13 UTC] mike at aqua-helix dot com
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) {
	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);



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-09 21:35 UTC]
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
In case this was a documentation problem, the fix will show up soon at

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

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Oct 04 17:01:26 2023 UTC