Fix nesting tdb_traverse in a transaction
authorVolker Lendecke <vl@samba.org>
Tue, 20 May 2008 19:54:36 +0000 (21:54 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 20 May 2008 21:14:41 +0000 (14:14 -0700)
commitfd0b60a9e000f969cf99a8d670080cc7a52d97d8
tree52e9e0ea5bbbbb8359340661610c64b89f67d739
parent47eb2e8fa858d9f12637eb9a10466271335f61aa
Fix nesting tdb_traverse in a transaction

Calling tdb_traverse inside a transaction led to the transaction lock being
held indefinitely. This was caused by the tdb_transaction_lock/unlock inside
tdb_traverse: The transaction code holds the global lock at offset
TRANSACTION_LOCK. The call to tdb_transaction_lock does nothing because the
transaction_lock is already being held. tdb_transaction_unlock inside tdb_wrap
resets tdb->have_transaction_lock but does not release the kernel-level fcntl
lock. transaction_commit later on does not release that fcntl lock either,
because tdb->have_transaction_lock was already reset by tdb_transaction().

This patch does fix that problem for me. An alternative would be to make
tdb->have_transaction_lock a counter that can cope with proper nesting, maybe
in other places as well.

Volker
source/lib/tdb/common/traverse.c