Hello CC,
On 23-Jun-01 17:25:54, you wrote:
>I'm having trouble understanding the docs and annotations on flock(). I've
>got a script that needs to overwrite a data file's contents without letting
>Instance B of that script truncate the data file while Instance A is still
>writing new content to it. How do other people do this? It seems to me
Let me guess: you are developing a cache system, right? :-)
>that if I fopen() in "w" or "w+" mode, then the file will be truncated
>before it can be determined whether there's a lock already in effect or the
>current instance can acquire a lock; but flock() requires a filepointer
>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?
I know that second solution works, but I don't know about its portability.
>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.").
If you don't want to wait in case it is not possible to obtain the lock
right away, using non-blocking locks.
Regards,
Manuel Lemos
Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
--
E-mail: [EMAIL PROTECTED]
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]