#45013 [Opn->Fbk]: Semaphore cannot be released under certain circumstances.
| From: | jani@php.net | Date: | Fri, 11 Jul 2008 21:46:01 +0000 |
| Subject: | #45013 [Opn->Fbk]: Semaphore cannot be released under certain circumstances. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-126557@lists.php.net to get a copy of this message | ||
ID: 45013
Updated by: jani@php.net
Reported By: andre at koethur dot de
-Status: Open
+Status: Feedback
Bug Type: Semaphore related
Operating System: Linux
PHP Version: 4.4.8
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
If you can reproduce this problem using latest PHP 5.2 snapshot, update
the version string to contain: 5.2CVS-2008mmdd
Previous Comments:
------------------------------------------------------------------------
[2008-05-15 20:47:33] andre at koethur dot de
Description:
------------
If I acqure a semaphore in one script, then it is not possible to
release it in another script, even if I set "auto_release" to false.
As I have found out, it has something to do with the "count" attribute
of the "sysvsem_sem"-structure. This value is really only needed by
the
"auto_release"-functionality, so it should be safe to ignore it in
php_sysvsem_semop()-function.
The current cvs-version of sysvsem.c says on line 290:
if (!acquire && sem_ptr->count == 0)
I suggest to change it to:
if (!acquire && sem_ptr->count == 0 && sem_ptr->auto_release)
Reproduce code:
---------------
First script, acquire semaphore:
<?php
$sem_id = sem_get(2405, 1, 0666, false);
if ($sem_id !== false) if (sem_acquire($sem_id)) echo 'Sem acquired!';
?>
Second script, release semaphore:
<?php
$sem_id = sem_get(2405, 1, 0666, false);
if ($sem_id !== false) if (sem_release($sem_id)) echo 'Sem released!';
?>
Expected result:
----------------
The second script should run without errors/warnings and the semaphore
should be released.
Actual result:
--------------
Warning: sem_release() [function.sem-release]: SysV semaphore 2 (key
0x965) is not currently acquired
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45013&edit=1