tdb: Reimplementation of Metze's "lib/tdb: if we know pwrite and pread are thread...
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 30 Jul 2009 02:22:08 +0000 (11:52 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 4 Aug 2009 07:20:52 +0000 (16:50 +0930)
commit8d0d432ab7766d9c0f9868fd77e48b9b5cc5d9f9
tree8f64edcfb99c7859b32800b7c604aab6c9c79aa6
parent8b6a5bba93843cd83b7b386b82949ad88f29884a
tdb: Reimplementation of Metze's "lib/tdb: if we know pwrite and pread are thread/fork safe tdb_reopen_all() should be a noop".

This version just wraps the reopen code, so we still re-grab the lock and do
the normal sanity checks.

The reason we do this at all is to avoid global fd limits, see:
http://forums.fedoraforum.org/showthread.php?t=210393

Note also that this whole reopen concept is fundamentally racy: if the parent
goes away before the child calls tdb_reopen_all, the database can be left
without an active lock and another TDB_CLEAR_IF_FIRST opener will clear it.
A fork_with_tdbs() wrapper could use a pipe to solve this, but it's hardly
elegant (what if there are other independent things which have similar needs?).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
lib/tdb/common/open.c