Re: using cdb for 'update' without race condition?
[email protected] (Paul Jarc) Fri, 11 Apr 2008 12:17:57 -0400
| Newsgroups | gmane.comp.djb.cdb |
|---|---|
| Organization | What did you have in mind? A short, blunt, human pyramid? |
| Message-ID | <[email protected]> |
ari edelkind <[email protected]> wrote: > set -o noclobber > > while ! (exec >"$REMASTER_FILE") 2>&- > do > sleep 1 > done Ah, so you're talking about O_EXCL, not locking. Yes, that will work, but again, you're busy-waiting instead of letting the kernel wake you up when it's your turn. Also, if the script gets killed in the middle of making an update, you'll have a stale remaster file blocking all further updates until you intervene manually. With a permanent, separate file used just for locking, you have no busy-waiting and (if you're not on NFS) no chance of stale locks. paul