Re: [PHP4BETA] flock() - how does this baby work?

[email protected] ("Manuel Lemos") 4 Jun 2000 1:25:21 -0200
Newsgroups php.version4
Message-ID <[email protected]>
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/[email protected]
--
E-mail: [email protected]
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--