From 0867a670ad23e09c62a35b88c49ce108b19af3d7 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 29 Mar 2010 09:51:16 +0200 Subject: [PATCH] Add File and Line info to rw_lock for lmgr --- bacula/src/lib/rwlock.c | 4 ++-- bacula/src/lib/rwlock.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bacula/src/lib/rwlock.c b/bacula/src/lib/rwlock.c index d112c6822a..c08ca72342 100644 --- a/bacula/src/lib/rwlock.c +++ b/bacula/src/lib/rwlock.c @@ -219,7 +219,7 @@ int rwl_readunlock(brwlock_t *rwl) * Lock for write access, wait until locked (or error). * Multiple nested write locking is permitted. */ -int rwl_writelock(brwlock_t *rwl) +int rwl_writelock_p(brwlock_t *rwl, const char *file, int line) { int stat; @@ -234,7 +234,7 @@ int rwl_writelock(brwlock_t *rwl) pthread_mutex_unlock(&rwl->mutex); return 0; } - lmgr_pre_lock(rwl, rwl->priority, __FILE__, __LINE__); + lmgr_pre_lock(rwl, rwl->priority, file, line); if (rwl->w_active || rwl->r_active > 0) { rwl->w_wait++; /* indicate that we are waiting */ pthread_cleanup_push(rwl_write_release, (void *)rwl); diff --git a/bacula/src/lib/rwlock.h b/bacula/src/lib/rwlock.h index a6c5c27bfa..447751f9d6 100644 --- a/bacula/src/lib/rwlock.h +++ b/bacula/src/lib/rwlock.h @@ -66,6 +66,8 @@ typedef struct s_rwsteal_tag { {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, \ PTHREAD_COND_INITIALIZER, RWLOCK_VALID, 0, 0, 0, 0} +#define rwl_writelock(x) rwl_writelock_p((x), __FILE__, __LINE__) + /* * read/write lock prototypes */ @@ -74,7 +76,8 @@ extern int rwl_destroy(brwlock_t *rwlock); extern int rwl_readlock(brwlock_t *rwlock); extern int rwl_readtrylock(brwlock_t *rwlock); extern int rwl_readunlock(brwlock_t *rwlock); -extern int rwl_writelock(brwlock_t *rwlock); +extern int rwl_writelock_p(brwlock_t *rwlock, + const char *file="*unknown*", int line=0); extern int rwl_writetrylock(brwlock_t *rwlock); extern int rwl_writeunlock(brwlock_t *rwlock); -- 2.39.5