note 87433 added to function.flock
| From: | yesmarklapointe at hotmail dot com | Date: | Fri, 05 Dec 2008 00:35:41 +0000 |
| Subject: | note 87433 added to function.flock | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147654@lists.php.net to get a copy of this message | ||
Perhaps not what you are looking for, but seems to me that to avoid a race condition you have to
end the race, that is, stop allowing multi-threaded or parallel processes to do the file
manipulation part of the overall application. Put the data outside the competing scripts and let a
separate process handle the transfer or replacement or storage in a deterministic way ⦠if you
can wait that long for it. For example, why not have a chron job process temporary files in a
special directory, making their individual changes to the ârealâ file based on something
simple like which one is stored first in this special directory. All of your scripts have to put
their file change requests into this directory by a sufficiently random naming scheme ⦠but
maintaining an incremental aspect to the naming so they are in order for processing. In this
example, besides the chron job, no other script should have more than read access to the real file.
----
Server IP: 69.147.83.197
Probable Submitter: 72.223.11.42
----
Manual Page -- http://www.php.net/manual/en/function.flock.php
Edit -- https://master.php.net/note/edit/87433
Del: integrated -- https://master.php.net/note/delete/87433/integrated
Del: useless -- https://master.php.net/note/delete/87433/useless
Del: bad code -- https://master.php.net/note/delete/87433/bad+code
Del: spam -- https://master.php.net/note/delete/87433/spam
Del: non-english -- https://master.php.net/note/delete/87433/non-english
Del: in docs -- https://master.php.net/note/delete/87433/in+docs
Del: other reasons-- https://master.php.net/note/delete/87433
Reject -- https://master.php.net/note/reject/87433
Search -- https://master.php.net/manage/user-notes.php