s3-dbwrap: Move "lock_order" initialization to db_open_xx
authorVolker Lendecke <vl@samba.org>
Thu, 15 Mar 2012 10:10:35 +0000 (11:10 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 16 Mar 2012 10:20:10 +0000 (11:20 +0100)
source3/lib/dbwrap/dbwrap_ctdb.c
source3/lib/dbwrap/dbwrap_open.c
source3/lib/dbwrap/dbwrap_tdb.c
source3/lib/dbwrap/dbwrap_tdb.h

index d50f75ef5d9b37ff58cf0b470a5bbbb70aea8ba9..41adfd8243cb73234e57edcca51cee4eecda7aa9 100644 (file)
@@ -1505,6 +1505,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
        db_path = ctdbd_dbpath(conn, db_ctdb, db_ctdb->db_id);
 
        result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);
+       result->lock_order = lock_order;
 
        /* only pass through specific flags */
        tdb_flags &= TDB_SEQNUM;
index 731529680e454a1b6f53069a388b6efdd1a192ba..06ae7c6effcadf4e01a4513ae1384f2b73678dbe 100644 (file)
@@ -123,10 +123,8 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
 
        if (result == NULL) {
                result = db_open_tdb(mem_ctx, name, hash_size,
-                                    tdb_flags, open_flags, mode);
-       }
-       if (result != NULL) {
-               result->lock_order = lock_order;
+                                    tdb_flags, open_flags, mode,
+                                    lock_order);
        }
        return result;
 }
index 454073a52f1e7b5273cc73ffe05de50ee1eb4939..46d6cdb8d1e3a59ad8e26970953e818a28174c35 100644 (file)
@@ -343,7 +343,8 @@ static int db_tdb_transaction_cancel(struct db_context *db)
 struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
                               const char *name,
                               int hash_size, int tdb_flags,
-                              int open_flags, mode_t mode)
+                              int open_flags, mode_t mode,
+                              enum dbwrap_lock_order lock_order)
 {
        struct db_context *result = NULL;
        struct db_tdb_ctx *db_tdb;
@@ -361,6 +362,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
                DEBUG(0, ("talloc failed\n"));
                goto fail;
        }
+       result->lock_order = lock_order;
 
        db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
                                     open_flags, mode, lp_ctx);
index 86673d09caf4be4f29d5b1f1b8dc4fe1d0e64579..1f7a223c7027a91dd7aeddf0777e0a78f5220496 100644 (file)
@@ -27,7 +27,8 @@ struct db_context;
 struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
                               const char *name,
                               int hash_size, int tdb_flags,
-                              int open_flags, mode_t mode);
+                              int open_flags, mode_t mode,
+                              enum dbwrap_lock_order lock_order);
 
 
 #endif /* __DBWRAP_TDB_H__ */