diff options
author | Alexander Drozdov <al.drozdov@gmail.com> | 2015-04-28 07:42:43 +0300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2015-04-28 21:28:18 +0200 |
commit | e4fe0aff5252b37536eec4a130d4e40a05a56ddb (patch) | |
tree | 9a9b41ee36cbbf7316910ebe4fd9ef41ae6d55e2 | |
parent | 06f4ba321761d6fdfb4a722849da6a11f6779a0a (diff) | |
download | samba-e4fe0aff5252b37536eec4a130d4e40a05a56ddb.tar.gz |
tdb: introduce tdb_chainlock_read_nonblock(), a nonblock variant of tdb_chainlock_read()
Signed-off-by: Alexander Drozdov <al.drozdov@gmail.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | lib/tdb/common/lock.c | 7 | ||||
-rw-r--r-- | lib/tdb/include/tdb.h | 1 |
2 files changed, 8 insertions, 0 deletions
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); |