summaryrefslogtreecommitdiff
path: root/lib/tdb_compat/tdb_compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdb_compat/tdb_compat.c')
-rw-r--r--lib/tdb_compat/tdb_compat.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/tdb_compat/tdb_compat.c b/lib/tdb_compat/tdb_compat.c
index 0406eff55e..7fd3caf6b5 100644
--- a/lib/tdb_compat/tdb_compat.c
+++ b/lib/tdb_compat/tdb_compat.c
@@ -38,6 +38,30 @@ enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb)
return ecode;
}
+enum TDB_ERROR tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key)
+{
+ union tdb_attribute locking, orig;
+ enum TDB_ERROR ecode;
+
+ orig.base.attr = TDB_ATTRIBUTE_FLOCK;
+ ecode = tdb_get_attribute(tdb, &orig);
+ if (ecode != TDB_SUCCESS)
+ return ecode;
+
+ /* Replace locking function with our own. */
+ locking = orig;
+ locking.flock.data = &orig;
+ locking.flock.lock = lock_nonblock;
+
+ ecode = tdb_set_attribute(tdb, &locking);
+ if (ecode != TDB_SUCCESS)
+ return ecode;
+
+ ecode = tdb_chainlock(tdb, key);
+ tdb_unset_attribute(tdb, TDB_ATTRIBUTE_FLOCK);
+ return ecode;
+}
+
/* For TDB1 tdbs, read traverse vs normal matters: write traverse
locks the entire thing! */
int64_t tdb_traverse_read_(struct tdb_context *tdb,