Re: Practical flock() implementation
| From: | Richard Lynch | Date: | Mon, 25 Jun 2001 06:31:38 +0000 |
| Subject: | Re: Practical flock() implementation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55102@lists.php.net to get a copy of this message | ||
> argument, so don't I *have* to fopen the file before going to flock()? Or
> should I fopen first in "r" mode, acquire the lock, then re-open in "w"
> mode, counting on the lock to stay in effect even though it's a different
> file pointer?
Yup. You are holding the lock, and it's yours
> I'd also be grateful if someone could clarify the difference between
> blocking and locking (i.e. "If you don't want flock() to block while
> locking, add LOCK_NB (4 prior to PHP 4.0.1) to operation.").
blocking == Do you want your script to just sit there waiting forever for
the lock?
Possibly spurious NOTE:
Most beginners who think they need a lock file are doing something that
should be in a database, but they are not familiar with databases, so use
files instead.
Don't.
The database guys have worked really hard to (A) take care of all these
locking issues and (B) make it just as easy to use as files.
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm