Volker Lendecke Volker.Lendecke at SerNet.DE
Tue May 17 06:17:15 MDT 2011


For years I have had a low-prio thread sitting in my mind
about getting rid of the fcntl calls for tdb access. A
couple of years ago I've discovered PTHREAD_PROCESS_SHARED
which make pthread mutexes cross-process. They are not
robust though, if a lock holder dies the mutex won't be
unlocked automatically. Now I was pointed out that in SUSV4
we have

which gives seems to do exactly what we want. I've written a
tiny non-error checking test program. In one window, run

./mutex /tmp/mutexfile init

and in another windows run

./mutex /tmp/mutexfile

and kill -9 the first instance. The second one will be woken

We get an additional benefit over fcntl locks: We can tell
whether a lock holder dies hard while holding a lock, so we
at least know when the tdb is potentially hosed.

To me this looks VERY promising. The first caller does not
do any syscalls on my Ubuntu Linux box to lock the mutex,
the second caller sits in a futex call.



SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mutex.c
Type: text/x-csrc
Size: 1493 bytes
Desc: not available
URL: <>

More information about the samba-technical mailing list