Reputation: 184
I need help in this scenario,
I need to write in the file for some reason during the handling of request, So I used flock to be sure there is just one request is writing in the file in the same time.
My questions is what happen when a request call flock during locked by other request. is it wait until released or just return false and do not open the file?
Upvotes: 1
Views: 155
Reputation: 28850
According to the documentation
By default, this function will block until the requested lock is acquired
Just be sure to use the right lock (see doc)
basically a writer waits for an exclusive lock, meaning it waits for all readers or the current writer to release the(ir) lock(s). While readers may be more than one to read the file.
and, to release the lock
Upvotes: 3