Forum Moderators: coopster

Message Too Old, No Replies

Protection measures againist allready open files with fopen()

         

blaketar

12:04 am on Oct 27, 2006 (gmt 0)

10+ Year Member



I am attempting to pin down a good practice to use with some of our code which uses fopen() to re-write files on our server when they are updated with information. My main concern is what happens when the following two instances collide: One person is requesting the file via http and at the same instance the server is attempting to update the file via fopen().

I could just as easily check to see if fopen succeeded and if not loop a couple more times and make the same attempt, seems clunky to me however.

Hoping someone may be able to share some insight or possibly a solution to making sure the read-write issues are microseconds behind each other...

Thanks All!

Little_G

12:09 am on Oct 27, 2006 (gmt 0)

10+ Year Member



Hi,

Maybe flock [php.net] is what your looking for.

Andrew