[dm-devel] [PATCH 02/35] libmultipath: add trylock() helper

Benjamin Marzinski bmarzins at redhat.com
Wed Sep 15 22:07:23 UTC 2021


On Fri, Sep 10, 2021 at 01:40:47PM +0200, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
> 
> Add a small helper.
> 
> Signed-off-by: Martin Wilck <mwilck at suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---
>  libmultipath/lock.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libmultipath/lock.h b/libmultipath/lock.h
> index a170efe..d99eedb 100644
> --- a/libmultipath/lock.h
> +++ b/libmultipath/lock.h
> @@ -12,6 +12,11 @@ static inline void lock(struct mutex_lock *a)
>  	pthread_mutex_lock(&a->mutex);
>  }
>  
> +static inline int trylock(struct mutex_lock *a)
> +{
> +	return pthread_mutex_trylock(&a->mutex);
> +}
> +
>  static inline int timedlock(struct mutex_lock *a, struct timespec *tmo)
>  {
>  	return pthread_mutex_timedlock(&a->mutex, tmo);
> -- 
> 2.33.0




More information about the dm-devel mailing list