summaryrefslogtreecommitdiff
path: root/source4/lib/tdb/common/traverse.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-05-21 12:13:45 +1000
committerAndrew Bartlett <abartlet@samba.org>2008-05-21 12:13:45 +1000
commitfdec7fdaf5d4150e14311d9b3bb2da7358a407ff (patch)
tree5fbeb5de11214711f780e69c5e9ad1210c2e861e /source4/lib/tdb/common/traverse.c
parent2f773ff347ec2828f94f4980a3aedbde37009737 (diff)
parent6d4424cd45333c3029b0272528485dd2b3f8e620 (diff)
downloadsamba-fdec7fdaf5d4150e14311d9b3bb2da7358a407ff.tar.gz
samba-fdec7fdaf5d4150e14311d9b3bb2da7358a407ff.tar.bz2
samba-fdec7fdaf5d4150e14311d9b3bb2da7358a407ff.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-local
(This used to be commit 7594f79db6a0e8a46e2863829e5e050b03dfaec1)
Diffstat (limited to 'source4/lib/tdb/common/traverse.c')
-rw-r--r--source4/lib/tdb/common/traverse.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c
index 07b0c23858..69c81e6e98 100644
--- a/source4/lib/tdb/common/traverse.c
+++ b/source4/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;
}