Convert in_transaction to a bool. Add the same fix Volker
authorJeremy Allison <jra@samba.org>
Tue, 20 May 2008 21:18:58 +0000 (14:18 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 20 May 2008 21:19:24 +0000 (14:19 -0700)
used for tdb_traverse() to tdb_traverse_read().
Jeremy.

source/lib/tdb/common/traverse.c

index 5a31742e7b548a28cd71c6587e57b5fc168eaf6c..69c81e6e98fd27b7a4d8d86c7c6f620e64cd552a 100644 (file)
@@ -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,7 +237,7 @@ int tdb_traverse(struct tdb_context *tdb,
 {
        struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK };
        int ret;
-       int in_transaction = (tdb->transaction != NULL);
+       bool in_transaction = (tdb->transaction != NULL);
 
        if (tdb->read_only || tdb->traverse_read) {
                return tdb_traverse_read(tdb, fn, private_data);