From xemacs-m  Thu Jul 10 22:42:54 1997
Received: from bittersweet.inetarena.com (karlheg@bittersweet.inetarena.com [206.129.216.38])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id WAA17588
	for <xemacs-beta@xemacs.org>; Thu, 10 Jul 1997 22:42:52 -0500 (CDT)
Received: (from karlheg@localhost)
	by bittersweet.inetarena.com (8.8.5/8.8.5) id UAA23792;
	Thu, 10 Jul 1997 20:42:09 -0700
To: XEmacs BETA <xemacs-beta@xemacs.org>
Subject: Re: filelock.c
References: <199707101802.OAA07461@anthem.CNRI.Reston.Va.US>
X-Face: /Q}=yl}1_v7nP)xXo5XjG8+tl@=uVu7o5u6)f]zN?+<hB!K.m9:[|*p34jVN`O;:XZXVSy>/\R>qDt(t8w!-i{(y0"`jFw^uk8inzO9wXabd'CdjUWfC\GHi:6nO*YC89#-qD>Q4r%9!V"<RYJ=7D#$";q=zML5'!=wvXk^$`6FT=5CMofQX)WUKt0p:OKl.mFOXx/D
Mime-Version: 1.0 (generated by tm-edit 7.108)
Content-Type: text/plain; charset=US-ASCII
From: karlheg+xemacs@inetarena.com (Karl M. Hegbloom)
Date: 10 Jul 1997 20:42:09 -0700
In-Reply-To: "Barry A. Warsaw"'s message of "Thu, 10 Jul 1997 14:02:28 -0400"
Message-ID: <87wwmy5k6m.fsf@bittersweet.inetarena.com>
Lines: 50
X-Mailer: Gnus v5.4.62/XEmacs 20.3(beta12) - "Helsinki"

>>>>> Barry A Warsaw writes:

    BAW> Has anybody thought about changing the way files are locked
    BAW> (e.g. filelock.c) in XEmacs?  The current approach, sync'd
    BAW> with 19.30 is very troublesome when XEmacs is maintained in a
    BAW> networked environment over NFS.  I don't know that Emacs 20's
    BAW> approach is any better, but it is definitely different.

 There's been talk on the Debian devel list about proper algorithm for
creating a lock semaphore file over NFS where the nfs implementation
doesn't support `flock', `fcntl' or `lockf' locking.

 I don't know a whole lot about that; I've no nfs here.

 What they do is open O_CREAT a temp file, then make a link to it with
the .lock name, since link is guaranteed to be an atomic operation.
Then they stat check the link count, and see that it's == 2.  The age
of the lockfile is checked, using the timestamps from the stat call,
since the clock on one computer might be set differently from the
clock on the other.  The .lock file is touched every so often, and a
five minute old lockfile is considered to be stale.

 One man wrote a libnfslock.so that you LD_PRELOAD.  It replaces
create() and open() with ones that are safe over nfs.  I've a copy of
the sources to it; (the URL is in the list archive).  He took much of
the code for it from `procmail'.  It checks the age of the file using
the stat value and the local clock; I imagine that will change
shortly, as it won't deal with clock skew properly.  (actually the
proper way to deal with clock skew is to reset the clocks.)

 I guess that if you want to have clash detection where you might be
using efs[1] a lot, you'd have to decide on a central directory to put
the emacs lockfiles, and create them using that algorithm, or a
similar one using a combination of ftp/rsh/nfs or something.[2]

 Hmmm.  For ftp, couldn't `touch' be put into the ftp/bin directory,
and run by efs to make the lockfile?


Footnotes: 
[1]  Hmm. I wonder how `omirr' will deal with that?

[2]  You tell me and we'll both know.

-- 
mailto:karlheg+sig@inetarena.com (Karl M. Hegbloom)
http://www.inetarena.com/~karlheg
Portland, OR  USA
Debian GNU 1.3  Linux 2.1.36 AMD K5 PR-133

