[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-2388-ga0e1d8a
Jeremy Allison
jra at samba.org
Tue May 20 21:20:00 GMT 2008
The branch, v3-2-test has been updated
via a0e1d8ac4dd9121312fd66ecb2e2942513df5a4b (commit)
via fd0b60a9e000f969cf99a8d670080cc7a52d97d8 (commit)
from 47eb2e8fa858d9f12637eb9a10466271335f61aa (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit a0e1d8ac4dd9121312fd66ecb2e2942513df5a4b
Author: Jeremy Allison <jra at samba.org>
Date: Tue May 20 14:18:58 2008 -0700
Convert in_transaction to a bool. Add the same fix Volker
used for tdb_traverse() to tdb_traverse_read().
Jeremy.
commit fd0b60a9e000f969cf99a8d670080cc7a52d97d8
Author: Volker Lendecke <vl at samba.org>
Date: Tue May 20 21:54:36 2008 +0200
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
-----------------------------------------------------------------------
Summary of changes:
source/lib/tdb/common/traverse.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/lib/tdb/common/traverse.c b/source/lib/tdb/common/traverse.c
index 07b0c23..69c81e6 100644
--- a/source/lib/tdb/common/traverse.c
+++ b/source/lib/tdb/common/traverse.c
@@ -204,18 +204,23 @@ int tdb_traverse_read(struct tdb_context *tdb,
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK };
int ret;
+ bool in_transaction = (tdb->transaction != NULL);
/* we need to get a read lock on the transaction lock here to
cope with the lock ordering semantics of solaris10 */
- if (tdb_transaction_lock(tdb, F_RDLCK)) {
- return -1;
+ if (!in_transaction) {
+ if (tdb_transaction_lock(tdb, F_RDLCK)) {
+ return -1;
+ }
}
tdb->traverse_read++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_read--;
- tdb_transaction_unlock(tdb);
+ if (!in_transaction) {
+ tdb_transaction_unlock(tdb);
+ }
return ret;
}
@@ -232,20 +237,25 @@ int tdb_traverse(struct tdb_context *tdb,
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK };
int ret;
+ bool in_transaction = (tdb->transaction != NULL);
if (tdb->read_only || tdb->traverse_read) {
return tdb_traverse_read(tdb, fn, private_data);
}
- if (tdb_transaction_lock(tdb, F_WRLCK)) {
- return -1;
+ if (!in_transaction) {
+ if (tdb_transaction_lock(tdb, F_WRLCK)) {
+ return -1;
+ }
}
tdb->traverse_write++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_write--;
- tdb_transaction_unlock(tdb);
+ if (!in_transaction) {
+ tdb_transaction_unlock(tdb);
+ }
return ret;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list