|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-15 20:47 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 11:00:01 2025 UTC |
/* 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?