From: Alexander Drozdov Date: Tue, 28 Apr 2015 04:42:43 +0000 (+0300) Subject: tdb: introduce tdb_chainlock_read_nonblock(), a nonblock variant of tdb_chainlock_read() X-Git-Tag: tdb-1.3.5~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e4fe0aff5252b37536eec4a130d4e40a05a56ddb;p=thirdparty%2Fsamba.git tdb: introduce tdb_chainlock_read_nonblock(), a nonblock variant of tdb_chainlock_read() Signed-off-by: Alexander Drozdov Reviewed-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c index 6644c4034e0..195dbb5daf2 100644 --- a/lib/tdb/common/lock.c +++ b/lib/tdb/common/lock.c @@ -858,6 +858,13 @@ _PUBLIC_ int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key) return tdb_unlock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK); } +_PUBLIC_ int tdb_chainlock_read_nonblock(struct tdb_context *tdb, TDB_DATA key) +{ + int ret = tdb_lock_nonblock(tdb, BUCKET(tdb->hash_fn(&key)), F_RDLCK); + tdb_trace_1rec_ret(tdb, "tdb_chainlock_read_nonblock", key, ret); + return ret; +} + /* record lock stops delete underneath */ int tdb_lock_record(struct tdb_context *tdb, tdb_off_t off) { diff --git a/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h index 03e429cc8a8..8478ca20d7b 100644 --- a/lib/tdb/include/tdb.h +++ b/lib/tdb/include/tdb.h @@ -884,6 +884,7 @@ int tdb_chainlock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainunlock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_read(struct tdb_context *tdb, TDB_DATA key); +int tdb_chainlock_read_nonblock(struct tdb_context *tdb, TDB_DATA key); int tdb_chainunlock_read(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_mark(struct tdb_context *tdb, TDB_DATA key); int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);