From: Eric Bollengier Date: Wed, 9 Dec 2009 13:49:49 +0000 (+0100) Subject: Add info in dump about lock priority X-Git-Tag: Release-5.0.0~165 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8702b643b7e9a358e1e0bd6216d3a6f9f5a8de8f;p=bacula%2Fbacula Add info in dump about lock priority --- diff --git a/bacula/src/lib/lockmgr.c b/bacula/src/lib/lockmgr.c index 5abf2a71d3..c2f7b875cb 100644 --- a/bacula/src/lib/lockmgr.c +++ b/bacula/src/lib/lockmgr.c @@ -37,7 +37,7 @@ V(mutex); use: - bthread_mutex_t mutex = BTHREAD_MUTEX_PRIORITY_1; + bthread_mutex_t mutex = BTHREAD_MUTEX_PRIORITY(1); P(mutex); ... V(mutex); @@ -283,9 +283,10 @@ public: fprintf(fp, "threadid=%p max=%i current=%i\n", (void *)thread_id, max, current); for(int i=0; i<=current; i++) { - fprintf(fp, " lock=%p state=%s %s:%i\n", + fprintf(fp, " lock=%p state=%s priority=%i %s:%i\n", lock_list[i].lock, (lock_list[i].state=='W')?"Wanted ":"Granted", + lock_list[i].priority, lock_list[i].file, lock_list[i].line); } } @@ -302,10 +303,11 @@ public: * Call before a lock operation (mark mutex as WANTED) */ virtual void pre_P(void *m, int priority, - const char *f="*unknown*", int l=0) { + const char *f="*unknown*", int l=0) + { + int max_prio = max_priority; ASSERT_p(current < LMGR_MAX_LOCK, f, l); ASSERT_p(current >= -1, f, l); - ASSERT_p(!priority || priority >= max_priority, f, l); lmgr_p(&mutex); { current++; @@ -319,6 +321,7 @@ public: max_priority = MAX(priority, max_priority); } lmgr_v(&mutex); + ASSERT_p(!priority || priority >= max_prio, f, l); } /* diff --git a/bacula/src/lib/lockmgr.h b/bacula/src/lib/lockmgr.h index 7b7017f8d1..03210a9880 100644 --- a/bacula/src/lib/lockmgr.h +++ b/bacula/src/lib/lockmgr.h @@ -157,9 +157,10 @@ int lmgr_thread_create(pthread_t *thread, /* Define USE_LOCKMGR_PRIORITY to detect mutex wrong order */ #ifdef USE_LOCKMGR_PRIORITY -# define BTHREAD_MUTEX_PRIORITY(p) {PTHREAD_MUTEX_INITIALIZER, p} +# define BTHREAD_MUTEX_PRIORITY(p) {PTHREAD_MUTEX_INITIALIZER, p} #else -# define BTHREAD_MUTEX_PRIORITY(p) BTHREAD_MUTEX_NO_PRIORITY +# define BTHREAD_MUTEX_PRIORITY(p) BTHREAD_MUTEX_NO_PRIORITY +# define bthread_mutex_set_priority(x,y) #endif #define bthread_mutex_lock(x) bthread_mutex_lock_p(x, __FILE__, __LINE__)