]> git.sur5r.net Git - bacula/bacula/commitdiff
Add info in dump about lock priority
authorEric Bollengier <eric@eb.homelinux.org>
Wed, 9 Dec 2009 13:49:49 +0000 (14:49 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Wed, 9 Dec 2009 14:34:59 +0000 (15:34 +0100)
bacula/src/lib/lockmgr.c
bacula/src/lib/lockmgr.h

index 5abf2a71d3a086db0d062adbba85e4ee354aace6..c2f7b875cb908df4d2b9987cd6db6555cafcc26a 100644 (file)
@@ -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);
    }
 
    /*
index 7b7017f8d12c8aa670ac51886ba24d4dabdce616..03210a9880001b8e242988efa362fa4e53d44ac8 100644 (file)
@@ -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__)