[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [afnog] lockf() and open() : Theoretical Questions



On Sat, 26 Jul 2003, Alan Barrett wrote:

> Other cooperating processes can tell that you have set an advisory lock,
> but non-cooperating processes are not prevented from reading/writing the
> file.

Thanks for the clarification.  I wonder, though, doesn't this pose
problems of inconsistency in situations where different pieces of software
(written by different people) access and attempt to modify the same files?
They may (by mistake or intentionally) write non-cooperative programs.

Is there some kind of standard that software written for FreeBSD must
conform to, perhaps?

> Just before the rename(), both old and new files are open and locked,
> and any other process trying to open the file by name will get the old
> version.  The rename() is atomic.  Just after the rename, both old and
> new files are open and locked, and any other process trying to open the
> file by name will get the new version.  As soon as you close the old
> file, it disappears, because there are no directory entries referring to
> it.

That solves it.  I'll then revert to mkstemp() instead of tmpfile().  I
suppose by atomic you mean it either completely fails or completely
succeeds?

Thank you very much, I do appreciate the help.

Ciao!
Gerald.
__________________________________________________
This is the Africa Network Operators' Group(AfNOG) 
technical discussion list.
The AfNOG website is: <http://www.afnog.org>