php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36824 flock with LOCK_NB not working
Submitted: 2006-03-22 20:53 UTC Modified: 2006-03-22 23:03 UTC
From: mauroi at digbang dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.1.2 OS: Win XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mauroi at digbang dot com
New email:
PHP Version: OS:

 

 [2006-03-22 20:53 UTC] mauroi at digbang dot com
Description:
------------
If I execute two consecutive times (in different browser tabs) the following script, LOCK_NB doesn't work. I mean, the second tab waits for the first to finish.

Thanks in advance.

Reproduce code:
---------------
<?
$handle = fopen('c:\foo', 'w+');
if ($handle)
{
	if (flock($handle, LOCK_EX + LOCK_NB))
	{
		echo 'locked!';
		sleep(5);
	}
	else
	{
		echo 'not locked!';
	}
	fclose($handle);
}
?>

Expected result:
----------------
1st:
locked!

2nd:
locked!

Actual result:
--------------
1st:
locked!

2nd:
not locked!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-22 21:05 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-03-22 21:51 UTC] mauroi at digbang dot com
Same problem.

Thanks.
 [2006-03-22 22:10 UTC] mauroi at digbang dot com
NOTE: I've also added a session_write_close() at the beginning.
 [2006-03-22 22:57 UTC] mauroi at digbang dot com
I'm sorry.
Seems that this happens only in Firefox (don't know why).
Even with a simple script:
<?
echo 'aa';
sleep(5);
echo 'bb';
?>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 03 08:01:31 2024 UTC