note 111985 added to function.flock
| From: | metamarkers at gmail dot com | Date: | Fri, 19 Apr 2013 01:43:46 +0000 |
| Subject: | note 111985 added to function.flock | ||
| Groups: | php.notes php.notes | ||
| Request: | Send a blank email to php-notes+get-194551@lists.php.net to get a copy of this message | ||
you should not be creating "clever workarounds" to circumvent expected locking behavior.
if some external process or library doesn't honor advisory locks then simply don't use it.
instead of using lock files, consider opening a file for reading and getting an exclusive lock on
the handle, then open a new handle for writing without obtaining a second lock. if you find yourself
doing gymnastics in order to "get an answer without asking a question" then there's
something wrong with your overall system and you're only going to dig yourself deeper into that
hole.
furthermore, don't put the thing that calls flock in a loop to "make sure its
locked". your process is not the only one running on a system, and this is what's known as
a "busy-waiting" antipattern and is well documented. you must learn to interact with the
operating system as it expects you to and accept and work around failures. a simple message like
"sorry, can't process your request at this time due to heavy server load. try again later.
here's some pictures of cats." is an acceptable message for a user to see. not expecting
and accepting failures is a failure in and of itself.
----
Server IP: 69.147.83.199
Probable Submitter: 67.182.168.147
----
Manual Page -- http://php.net/manual/en/function.flock.php
Edit -- https://master.php.net/note/edit/111985
Del: integrated -- https://master.php.net/note/delete/111985/integrated
Del: useless -- https://master.php.net/note/delete/111985/useless
Del: bad code -- https://master.php.net/note/delete/111985/bad+code
Del: spam -- https://master.php.net/note/delete/111985/spam
Del: non-english -- https://master.php.net/note/delete/111985/non-english
Del: in docs -- https://master.php.net/note/delete/111985/in+docs
Del: other reasons-- https://master.php.net/note/delete/111985
Reject -- https://master.php.net/note/reject/111985
Search -- https://master.php.net/manage/user-notes.php