dbwrap: dbwrap_fetch_locked_timeout().
[kai/samba-autobuild/.git] / lib / dbwrap / dbwrap.c
index d46044f0c4f6a7fcc3a88260c8032e95296de2f8..835bd599efcd2e12724ad06cebf281ebd5589bcf 100644 (file)
@@ -231,6 +231,33 @@ struct db_record *dbwrap_try_fetch_locked(struct db_context *db,
                ? db->try_fetch_locked : db->fetch_locked);
 }
 
+struct db_record *dbwrap_fetch_locked_timeout(struct db_context *db,
+                                             TALLOC_CTX *mem_ctx,
+                                             TDB_DATA key,
+                                             unsigned int timeout)
+{
+       struct db_record *rec;
+       struct dbwrap_lock_order_state *lock_order;
+       TALLOC_CTX *frame = talloc_stackframe();
+
+       lock_order = dbwrap_check_lock_order(db, frame);
+       if (lock_order == NULL) {
+               TALLOC_FREE(frame);
+               return NULL;
+       }
+       rec = db->fetch_locked_timeout
+               ? db->fetch_locked_timeout(db, mem_ctx, key, timeout)
+               : db->fetch_locked(db, mem_ctx, key);
+       if (rec == NULL) {
+               TALLOC_FREE(frame);
+               return NULL;
+       }
+       (void)talloc_steal(rec, lock_order);
+       rec->db = db;
+       TALLOC_FREE(frame);
+       return rec;
+}
+
 struct db_context *dbwrap_record_get_db(struct db_record *rec)
 {
        return rec->db;