Jeffry Killen wrote: > On Feb 17, 2015, at 3:28 PM, Christoph Becker wrote: > >> AFAIK is_writable() ignores any locks set via flock(). > > So what happens when the second user script tries to open the file for > write while there is a readonly lock on it? That depends. flock() is an advisory file locking mechanism (not a mandatory one). That means that the second script can simply ignore the lock of the first script by not calling flock(). > (I'm looking at the sleep() function to simulate the senario and find > out what might happen) Indeed, it seems to be a good idea to make some experiments with sleep(). > Actually, if the user that gets to the file first and his script puts a > lock on the file and > then removes it, it would be alright, then the second users script can > proceed. To make it clear: the lock will only last for a small fraction of a second usually. > I know, this raises some other issues like having to recconcile edits to > the same > file by different users. Indeed. IMO that is the real problem, and it has to be catered to. > But the second user could benefit from knowing that his script is being > delayed > until the lock is removed and a javascript call to location.reload() > might be used > to resubmit. If you're using flock() without LOCK_NB, than there's no need for any additional measures on the client side, because the second script will be paused until the first script removes the lock. -- Christoph M. Becker -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php