[PATCH] tdb: introduce tdb_chainlock_read_nonblock()
Jeremy Allison
jra at samba.org
Mon Apr 27 15:44:47 MDT 2015
On Fri, Apr 24, 2015 at 08:09:02AM +0300, Alexander Drozdov wrote:
> tdb has nonblock variants for many lock functions, for example:
>
> tdb_lockall() / tdb_lockall_nonblock()
> tdb_lockall_read() / tdb_lockall_read_nonblock()
> tdb_chainlock() / tdb_chainlock_nonblock()
>
> But there hasn't been nonblock variant for tdb_chainlock_read().
> >From 709ba75da5d401201ea34f94fc12f2244f4e815f Mon Sep 17 00:00:00 2001
> From: Alexander Drozdov <al.drozdov at gmail.com>
> Date: Fri, 24 Apr 2015 07:49:15 +0300
> Subject: [PATCH] tdb: introduce tdb_chainlock_read_nonblock(), a nonblock
> variant of tdb_chainlock_read()
>
> Signed-off-by: Alexander Drozdov <al.drozdov at gmail.com>
> ---
> lib/tdb/common/lock.c | 8 ++++++++
> lib/tdb/include/tdb.h | 1 +
> 2 files changed, 9 insertions(+)
>
> diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
> index 6644c40..67e2be6 100644
> --- a/lib/tdb/common/lock.c
> +++ b/lib/tdb/common/lock.c
> @@ -858,6 +858,14 @@ _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;
> + 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;
The above should be:
+_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;
to match the other versions of the code. Other than that LGTM.
Can we get a second Team reviewer ?
Jeremy.
More information about the samba-technical
mailing list