dbwrap: No lock_order check if not required
authorVolker Lendecke <vl@samba.org>
Fri, 6 Dec 2013 11:57:42 +0000 (11:57 +0000)
committerStefan Metzmacher <metze@samba.org>
Sat, 14 Dec 2013 09:10:41 +0000 (10:10 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/dbwrap/dbwrap.c

index 2c633cf..8270b63 100644 (file)
@@ -167,15 +167,6 @@ static struct dbwrap_lock_order_state *dbwrap_check_lock_order(
        static struct db_context *locked_dbs[DBWRAP_LOCK_ORDER_MAX];
        struct dbwrap_lock_order_state *state = NULL;
 
-       if (db->lock_order == 0) {
-               /*
-                * lock order 0 is for example for dbwrap_rbt without
-                * real locking. Return state nevertheless to avoid
-                * special cases.
-                */
-               return talloc_zero(mem_ctx, struct dbwrap_lock_order_state);
-       }
-
        if (db->lock_order > DBWRAP_LOCK_ORDER_MAX) {
                DEBUG(0,("Invalid lock order %d of %s\n",
                         (int)db->lock_order, db->name));
@@ -219,11 +210,13 @@ static struct db_record *dbwrap_fetch_locked_internal(
                                   TDB_DATA key))
 {
        struct db_record *rec;
-       struct dbwrap_lock_order_state *lock_order;
+       struct dbwrap_lock_order_state *lock_order = NULL;
 
-       lock_order = dbwrap_check_lock_order(db, mem_ctx);
-       if (lock_order == NULL) {
-               return NULL;
+       if (db->lock_order != 0) {
+               lock_order = dbwrap_check_lock_order(db, mem_ctx);
+               if (lock_order == NULL) {
+                       return NULL;
+               }
        }
        rec = db_fn(db, mem_ctx, key);
        if (rec == NULL) {