Excerpts from mail: 29-Oct-92 Re: Write Lock and AFS
[EMAIL PROTECTED] (2432)

> There is still a race between open and lock, but it's not as big.
> Somebody else could get a lock,append,close in there on you.
> I think you have to do something more like:
> fd1 = open (READ)     -- can't be RDWR because of AFS consistency semantics
> flock(fd1, EXCLUSIVE)         -- so nobody else can write it
>    fd2 = open (RDWR)
>    append(fd2, some stuff)
>    close(fd2);
> flock(fd1, UNLOCK)
> close(fd1);

Hey, thanks Lyle, that's just what I needed.

Quite a brilliant little solution: to open two file descriptors.  Use
one to establish that this process owns the lock, then the other to open
and append the current version of the file.  I can't say I understand
the "AFS consistency semantics" issue you referred to, but I can see how
this should work.

I gave it a try and it seems to work great.  Thanks a lot, you made my day.

Kris Davis ([EMAIL PROTECTED], krisd@rchland, krisd@rchvmw2)
Microcode Development Environment  Dept213
1-507-253-3707  IBM Rochester, MN

Reply via email to