Working on a project which requires us to store data in plain ASCII text files. The text files will be both read and written to by PHP scripts.
My concern is file locking issues, basically a person opens a page, the file gets read into a variable, we flock() the file, stuff gets done, if it needs to be updated, we fwrite() and flock() to unlock the file.
My concern is that if we have a second visotr at the same time, and the file is flock()'ed by the first user, I don't want the first user to recieve an error... I'd rather have the script wait until the file is unlocked, and then do its stuff.
Not sure how to approach this, is there I way I can tell fopen() to wait until the script is unlocked... or to keep trying to 3 seconds or something or...?