Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mcdchg!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.wizards Subject: Re: Is HDB locking safe? Message-ID: <1990Aug18.002409.24200@chinet.chi.il.us> Date: 18 Aug 90 00:24:09 GMT References: <577@oglvee.UUCP> <4024@rtifs1.UUCP> Organization: Chinet - Public Access UNIX Lines: 18 In article peter@ficc.ferranti.com (Peter da Silva) writes: >> (a) A "sleep(1);" is not enough to avoid a race on a very busy system. >No sleep is ever enough. The system could simply be busier than you ever >imagined. You don't solve a race problem by narrowing the window: try >checking the return value of the "unlink": that's the point of failure. No, there is no problem if the unlink fails since the creation of a new lock file is done in such a way that only one process will succeed. The problem occurs when a process tests one lockfile and decides that no current process owns it, but the unlink() instead removes a file that was just created by another program going through a similar procedure. The sleep after the unlink() is intended to give any other processes that have read the contents of the old lockfile time to complete their unlink() call before a valid file is created. Les Mikesell les@chinet.chi.il.us