Re: [PHP4BETA] flock() - how does this baby work?
| From: | Manuel Lemos | Date: | Sun, 04 Jun 2000 03:25:21 +0000 |
| Subject: | Re: [PHP4BETA] flock() - how does this baby work? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-16120@lists.php.net to get a copy of this message | ||
Precedence: bulk
Hello Faisal,
On 28-May-00 20:33:42, you wrote:
>You can upgrade or degrade the lock without
>unlocking first! You can move to a shared
>lock from an exclusive lock...
>Try the flock Unix man page.
Once I read that it is not completely portable to do safe lock upgrading
and downgrading.
Anyway I realized that if you want to lock a file to get a shared lock to
later get a exclusive lock to truncate the file you need to open the file
with mode "r", get a shared lock, open the file again with mode "w" without
closing the first handle to truncate its contents write the new contents
and close the handles in reverse opening order. I am just not sure if this
is a better solution than upgrading/downgrading locks and using the newly
added truncate function. What do you think?
Regards,
Manuel Lemos
Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org
--
E-mail: mlemos@acm.org
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--