ID: 31363 Updated by: php-bugs@lists.php.net Reported By: ian at snork dot net -Status: Feedback +Status: No Feedback Bug Type: Filesystem function related Operating System: Debian woody (i386) PHP Version: 5.0.3 New Comment:
No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". Previous Comments: ------------------------------------------------------------------------ [2005-02-28 21:06:39] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2004-12-31 06:41:56] ian at snork dot net Description: ------------ This code works in PHP 4.3.0, but does not in PHP 5.0.3. When invoked, it will try to lock /tmp/test1, /tmp/test2 or /tmp/test3 for exclusive use, whichever is free. If none are, it will wait a second before cycling through with another attempt. When running concurrently, the first invocation correctly picks up /tmp/test1; the second and subsequent ones just cycle forever. For some reason, the non-blocking flock() only sets $block the first time. Reproduce code: --------------- while (!sleep(1)) foreach (array("/tmp/test1", "/tmp/test2", "/tmp/test3") as $path) if (flock($handle = fopen($path, "w"), LOCK_EX | LOCK_NB, $block) and !$block) { echo "Got $path\n"; sleep(10); echo "Releasing $path\n"; exit; } Expected result: ---------------- $ php5 flock_test.php & Got /tmp/test1 $ php5 flock_test.php & Got /tmp/test2 $ php5 flock_test.php & Got /tmp/test3 $ php5 flock_test.php & Releasing /tmp/test1 Got /tmp/test1 $ Actual result: -------------- $ php5 flock_test.php & Got /tmp/test1 $ php5 flock_test.php & $ php5 flock_test.php & $ php5 flock_test.php & $ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31363&edit=1