note 67065 added to ref.sem
| From: | chrissavery at removeme dot gmail dot com | Date: | Fri, 02 Jun 2006 20:18:08 +0000 |
| Subject: | note 67065 added to ref.sem | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-113009@lists.php.net to get a copy of this message | ||
I was confused by two things that caused strange behaviour in my use of semaphores with php scripts
running under apache.
Often enough page requests will end up being filled by the same process as other simultaneous
requests. So semaphores will block when you may not have expected.
Also note that sem_remove() will remove it for all processes, not just the calling one. So you have
to be sure that the last process running removes the semaphore and none before. I thought there was
some failures occurring when my child processes were dropping out with errors.
So you can't just use get, acquire, release, remove in one script that will be hit by a web
user. (1) They may end up in the same process and will wait on the other, and (2) the first one to
finish will destroy the semaphore for others.
I left out the remove call, and it works ok, but I still wonder if the semaphore is removed by php
when the last script that did a get finishes? Also creating a child process to do the work using
proc_open works to ensure seperate processes but to be careful you would want to limit the number
somehow as well.
----
Server IP: 66.163.161.117
Probable Submitter: 58.136.71.134 (proxied: 58.136.71.134)
----
X-Spam-Status: No, hits=3.4 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
REMOVE_REMOVAL_NEAR autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.sem.php
Edit -- http://master.php.net/note/edit/67065
Del: integrated -- http://master.php.net/note/delete/67065/integrated
Del: useless -- http://master.php.net/note/delete/67065/useless
Del: bad code -- http://master.php.net/note/delete/67065/bad+code
Del: spam -- http://master.php.net/note/delete/67065/spam
Del: non-english -- http://master.php.net/note/delete/67065/non-english
Del: in docs -- http://master.php.net/note/delete/67065/in+docs
Del: other reasons-- http://master.php.net/note/delete/67065
Reject -- http://master.php.net/note/reject/67065
Search -- http://master.php.net/manage/user-notes.php