From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id DAA22203 for ; Thu, 11 Apr 1996 03:14:57 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id MAA11999; Wed, 10 Apr 1996 12:25:48 -0400 (EDT) Resent-Date: Wed, 10 Apr 1996 12:25:48 -0400 (EDT) From: schaefer@z-code.ncd.com (Barton E. Schaefer) Message-Id: <960410092605.ZM16040@zyrcon.z-code.com> Date: Wed, 10 Apr 1996 09:26:05 -0700 In-Reply-To: Zefram "Re: History file locking?" (Apr 10, 1:50pm) References: <20845.199604101250@stone.dcs.warwick.ac.uk> Reply-To: schaefer@z-code.ncd.com X-Face: czU|*h"p8AX?4.I.yU.^s%TIMx|"-s,*'|#H^|e,QjE&!jL%<]:-.U/;khS%3a2BC5_d#)( mz=$$G0u9P&*N8cA~b[URf;lgKRif@#qEf[ltie#Gg0%6$b`e`k.Cgw:\qJx\\a7c(K7^3;gXW:e1@ J Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/909 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Apr 10, 1:50pm, Zefram wrote: } Subject: Re: History file locking? } } >Also things get quite complicated when the history file is on an NFS volume. } >Probaly some dot-locking method similar to the one used by sendmail & co } >should be used. } } I wouldn't bother -- it's only a history file. lockf() (and fcntl()) } locking work over NFS anyway; it's only flock() that doesn't. O_EXCL } isn't reliable over NFS, which makes .lock locking rather pointless. Unfortunately, lockf() and fcntl() locking over NFS are very unreliable in heterogenous networks, because they depend on all of nfsd, lockd, and statd to be both running and compatible on every machine. (Believe me, I *know* about this. Z-Mail has to do extremely reliable file locking in all sorts of circumstances.) And one of the failure modes for lockf/fcntl is to hang the process, so you may want to avoid that. It's actually possible to do .lock locking *more* reliably than lockf if you follow some special rules. Take a look at the file xcreat.c in the mush (mail users's shell) sources, or at the file locking routines in procmail. Essentially, you create a file with a psuedo-random name to avoid the O_EXCL problems, then you use link() to create the file you really want, and then you stat() to check whether the link and the psuedo-random file really are the same (in case of link races). However, Zefram is right that it's probably more effort than it's worth. -- Bart Schaefer Vice President, Technology, Z-Code Software schaefer@z-code.com Division of NCD Software Corporation http://www.well.com/www/barts