Closed Thread Icon

Topic awaiting preservation: [php] when to flock? Pages that link to <a href="https://ozoneasylum.com/backlink?for=24041" title="Pages that link to Topic awaiting preservation: [php] when to flock?" rel="nofollow" >Topic awaiting preservation: [php] when to flock?\

 
Author Thread
ninmonkeys
Nervous Wreck (II) Inmate

From: mn
Insane since: May 2004

posted posted 11-15-2004 07:26

When is flock() required?

I have a script that reads a file using file() but does not write to it, do I need to lock the file?

Or is it required only when writing to a file?

thanks,
--monkey

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 11-15-2004 12:09

you'll only need to php->flock() if the file is being changed.
But if it is, you'll need to lock on both reading and writing!
And of course you only need to lock if reading & writing could happen simultaniously - but that's a given in a web enviroment.

Oh, and I personally don't use file() because I can't tell it to read my files in binary.
And I hate having the OS convert my line endings for me.

So long,
->Tyberius Prime

PS: Turn this in a faq when the discussion is done.

« BackwardsOnwards »

Show Forum Drop Down Menu