OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Subject: Re: Databases... (DB & CDB in particular)
From: Richard Huxton (devarchonet.com)
Date: Fri Dec 08 2000 - 10:50:38 CST


----- Original Message -----
From: "Michael Tokarev" <mjttls.msk.ru>

> Wietse Venema wrote:
> >
> > Michael Ju. Tokarev:
> []
> > > it. So I now have a solution, -- that is:
> > >
> > > open(file.cdb)
> > > lock it (*)
> > > open(it again)
> > > compare fstats() on both
> > > close second one if ok (bail out or repeat if not)
> >
> > And at that point you lose the exclusive lock. Welcome to the world
> > of POSIX fcntl() locking, which is the only locking that Postfix
> > can use on System-V systems such as Solaris, HP-UX and others.
>
> Doh!!! Never heard about this behavour... Just tested this
> on Solaris and Linux, -- yes, if while holding a lock I
> open+close the same file in the same process (using another,
> different diledescriptor!), lock will be lost! Very
> surprizingly... And seemed to be a bit strange at a first
> view, -- I need to read POSIX specs about this carefully...
> Thanks for a point.

Slightly OT: but Stevens' Advanced Programming in the UNIX Environment
(Addison Wesley) is a good investment - 50 quid in the UK and I hardly ever
use it, but it pays for itself the first time you do.

He's also got a network programming book.

- Richard Huxton