Bug #51771 [Com]: fclose() seems not to unlock the file
| From: | crrodriguez at opensuse dot org | Date: | Wed, 12 May 2010 03:41:13 +0000 |
| Subject: | Bug #51771 [Com]: fclose() seems not to unlock the file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-150357@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51771&edit=1
ID: 51771
Comment by: crrodriguez at opensuse dot org
Reported by: kulakov74 at yandex dot ru
Summary: fclose() seems not to unlock the file
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: Linux
PHP Version: 5.3.2
New Comment:
Correct, take look at the changelog..it clearly says:
"Removed automatic file descriptor unlocking happening on shutdown
and/or stream
close (on all OSes). (Tony, Ilia)"
aka. the correct behaviour.
Previous Comments:
------------------------------------------------------------------------
[2010-05-08 11:48:04] kulakov74 at yandex dot ru
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 this bug report at http://bugs.php.net/bug.php?id=51771&edit=1