[sheepdog] [PATCH v2] introduce wrapper functions for pthread_rwlock

Liu Yuan namei.unix at gmail.com
Fri Aug 9 07:10:33 CEST 2013


On Fri, Aug 09, 2013 at 01:03:59PM +0900, MORITA Kazutaka wrote:
> Currently, we don't check the return values of pthread_rwlock_rdlock()
> and pthread_rwlock_wrlock().  When they returns an error, we can call
> pthread_rwlock_unlock() even if another thread has the lock.  This can
> lead to a bug which is difficult to find.
> 
> Those functions can actually return error.  For example, when
> pthread_rwlock_rdlock() is called when a write lock is already owned,
> it returns EDEADLK without locking.  It is difficult to make sure that
> we don't have this kind of deadlock, so checking the return values
> strictly is important to ensure our codes is correct.
> 
> Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> ---
> v2: Rename structure and functions name.
> 
>     sd_mutex_t         -> struct sd_lock
> 
>     sd_mutex_init()    -> sd_init_lock()
>     sd_mutex_unlock()  -> sd_unlock()
>     sd_mutex_rdlock()  -> sd_read_lock()
>     sd_mutex_wrlock()  -> sd_write_lock()
>     sd_mutex_destroy() -> sd_destroy_lock()

Applied thanks

Yuan



More information about the sheepdog mailing list