note 99334 added to function.pcntl-fork
| From: | me at osu1 dot php dot net | Date: | Wed, 11 Aug 2010 15:38:24 +0000 |
| Subject: | note 99334 added to function.pcntl-fork | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171572@lists.php.net to get a copy of this message | ||
in reply to julian below:
a) this is not really related to fork()
b) a much more elegant method is to avoid the race condition on the server-side,
with an atomic check and update operation:
update queue set worker_id=$id,status='processing' where worker_id is null and
status='free'
select * from queue where worker_id=$id
-- we now either have our job to process, or got none and sleep/try again
you might also do away with the status column if you delete jobs that are done,
or use affected_rows() to check if you grabbed a job successfully
----
Server IP: 212.124.37.9
Probable Submitter: 89.204.137.105
----
Manual Page -- http://www.php.net/manual/en/function.pcntl-fork.php
Edit -- https://master.php.net/note/edit/99334
Del: integrated -- https://master.php.net/note/delete/99334/integrated
Del: useless -- https://master.php.net/note/delete/99334/useless
Del: bad code -- https://master.php.net/note/delete/99334/bad+code
Del: spam -- https://master.php.net/note/delete/99334/spam
Del: non-english -- https://master.php.net/note/delete/99334/non-english
Del: in docs -- https://master.php.net/note/delete/99334/in+docs
Del: other reasons-- https://master.php.net/note/delete/99334
Reject -- https://master.php.net/note/reject/99334
Search -- https://master.php.net/manage/user-notes.php