in reply to Update in-place with temporary file and flocking
The basic idea is that the semaphore file is always empty -- it exists purely to establish a lock on some particular resource. Get the lock on the semaphore file, and the resource is yours until you release the semaphore. This eliminates all the loop-holes, race conditions and weirdness of trying to grab and hold a lock on something that you're trying to change.
Of course, this only works in the cases where everyone agrees to cooperate (or the project is designed to enforce cooperation) and "update access" to the shared resource is always moderated via the specified semaphore -- it won't help in the case where some folks think they can ignore the semaphore stuff and just start hacking away at the actual data file (e.g. with vi or whatever).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Update in-place with temporary file and flocking
by geohar (Acolyte) on Feb 19, 2004 at 09:27 UTC |