summaryrefslogtreecommitdiff
path: root/lib/dbwrap/dbwrap.c
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2012-06-22 15:07:44 +0930
committerRusty Russell <rusty@rustcorp.com.au>2012-06-22 07:35:17 +0200
commitf6eb187fdab6b8088bb065e418fe604c4eba7751 (patch)
tree7c9e0dac178585a87b412e5446a7e2069dd8275b /lib/dbwrap/dbwrap.c
parent431667b47c0eac3069ba1e643996619ab61975e5 (diff)
downloadsamba-f6eb187fdab6b8088bb065e418fe604c4eba7751.tar.gz
samba-f6eb187fdab6b8088bb065e418fe604c4eba7751.tar.bz2
samba-f6eb187fdab6b8088bb065e418fe604c4eba7751.zip
dbwrap: dbwrap_fetch_locked_timeout().
Implemented for ntdb and tdb; falls back to the non-timeout variant for others. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/dbwrap/dbwrap.c')
-rw-r--r--lib/dbwrap/dbwrap.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c
index d46044f0c4..835bd599ef 100644
--- a/lib/dbwrap/dbwrap.c
+++ b/lib/dbwrap/dbwrap.c
@@ -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;