#45013 [Com]: Semaphore cannot be released under certain circumstances.

From: Date: Wed, 02 Sep 2009 00:23:44 +0000
Subject: #45013 [Com]: Semaphore cannot be released under certain circumstances.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-141826@lists.php.net to get a copy of this message
ID: 45013 Comment by: www at qaaa dot de Reported By: andre at koethur dot de Status: No Feedback Bug Type: Semaphore related Operating System: Linux PHP Version: 4.4.8 New Comment: /* if (!acquire && sem_ptr->count == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "SysVadasdsad semaphore %ld (key 0x%x) is not currently acquired", Z_LVAL_P(arg_id), sem_ptr->key); RETURN_FALSE; } */ this was my way to get the correct result... but ive not sure if any side effects will come up with?! what do you want to restrict with the (!acquire && sem_ptr->count == 0) ? why should not release when the sem counter is 0? Previous Comments: ------------------------------------------------------------------------ [2009-09-01 23:07:53] www at qaaa dot de Same problem now with PHP 5.3.0 ------------------------------------------------------------------------ [2008-07-19 01:00:00] php-bugs at lists dot php dot net 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". ------------------------------------------------------------------------ [2008-07-11 21:46:00] jani@php.net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#141826) next »