From: Operating system: Linux PHP version: 5.3.2 Package: Filesystem function related Bug Type: Bug Bug description:fclose() seems not to unlock the file
Description: ------------ We have a script that runs in a multiprocess way and it uses flock() for interprocess communication. Things worked fine until we moved to PHP 5.3.2 where all the processes started to hang all of a sudden. I debugged the issues and tried several fixes but they didn't solve it. I made an extensive log of all the script did in order to find out the reason, and I got a situation with 4 scripts running trying to get a non-blocking lock every second, and all of them wrote "lock failed" to the log. At the same time none of them was supposed to hold the lock at that time. Finally I added an flock($hLock, LOCK_UN); before every fclose($hLock); and it is only that that they stopped handing. Test script: --------------- $H=fopen($LockFile, 'a'); flock($H, LOCK_EX); //... //flock($H, LOCK_UN); - the fix fclose($H); Expected result: ---------------- no deadlock Actual result: -------------- Deadlock -- Edit bug report at http://bugs.php.net/bug.php?id=51771&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51771&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51771&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51771&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51771&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51771&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51771&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51771&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51771&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51771&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51771&r=support Expected behavior: http://bugs.php.net/fix.php?id=51771&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51771&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51771&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51771&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51771&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51771&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51771&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51771&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51771&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51771&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51771&r=mysqlcfg