]> git.sur5r.net Git - bacula/bacula/commitdiff
Add USE_LOCKMGR_PRIORITY switch to enable new priority management
authorEric Bollengier <eric@eb.homelinux.org>
Wed, 9 Dec 2009 08:39:43 +0000 (09:39 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Wed, 9 Dec 2009 08:39:43 +0000 (09:39 +0100)
bacula/src/lib/lockmgr.c
bacula/src/lib/lockmgr.h
bacula/src/version.h

index 9315c4fb103de6a38e966b7735ac4eec2857a09a..5abf2a71d3a086db0d062adbba85e4ee354aace6 100644 (file)
@@ -910,10 +910,7 @@ void dbg_print_lock(FILE *fp)
 
 #include "lockmgr.h"
 #define BTHREAD_MUTEX_NO_PRIORITY      {PTHREAD_MUTEX_INITIALIZER, 0}
-#define BTHREAD_MUTEX_PRIORITY_1       {PTHREAD_MUTEX_INITIALIZER, 1}
-#define BTHREAD_MUTEX_PRIORITY_2       {PTHREAD_MUTEX_INITIALIZER, 2}
-#define BTHREAD_MUTEX_PRIORITY_3       {PTHREAD_MUTEX_INITIALIZER, 3}
-#define BTHREAD_MUTEX_PRIORITY_4       {PTHREAD_MUTEX_INITIALIZER, 4}
+#define BTHREAD_MUTEX_PRIORITY(p)      {PTHREAD_MUTEX_INITIALIZER, p}
 #undef P
 #undef V
 #define P(x) bthread_mutex_lock_p(&(x), __FILE__, __LINE__)
@@ -926,9 +923,9 @@ bthread_mutex_t mutex3 = BTHREAD_MUTEX_NO_PRIORITY;
 bthread_mutex_t mutex4 = BTHREAD_MUTEX_NO_PRIORITY;
 bthread_mutex_t mutex5 = BTHREAD_MUTEX_NO_PRIORITY;
 bthread_mutex_t mutex6 = BTHREAD_MUTEX_NO_PRIORITY;
-bthread_mutex_t mutex_p1 = BTHREAD_MUTEX_PRIORITY_1;
-bthread_mutex_t mutex_p2 = BTHREAD_MUTEX_PRIORITY_2;
-bthread_mutex_t mutex_p3 = BTHREAD_MUTEX_PRIORITY_3;
+bthread_mutex_t mutex_p1 = BTHREAD_MUTEX_PRIORITY(1);
+bthread_mutex_t mutex_p2 = BTHREAD_MUTEX_PRIORITY(2);
+bthread_mutex_t mutex_p3 = BTHREAD_MUTEX_PRIORITY(3);
 static const char *my_prog;
 
 void *self_lock(void *temp)
index afce8bd180e2b4a3e3930913cb81f02baa62700f..d84bcd7ee02b45fd92b3c51be4705f1e7af98868 100644 (file)
@@ -150,22 +150,25 @@ int lmgr_thread_create(pthread_t *thread,
                        const pthread_attr_t *attr,
                        void *(*start_routine)(void*), void *arg);
 
-/* 
- * Define _LOCKMGR_COMPLIANT to use real pthread functions
- */
-
-#define BTHREAD_MUTEX_PRIORITY(p)      {PTHREAD_MUTEX_INITIALIZER, p}
 #define BTHREAD_MUTEX_NO_PRIORITY      {PTHREAD_MUTEX_INITIALIZER, 0}
-#define BTHREAD_MUTEX_PRIORITY_1       {PTHREAD_MUTEX_INITIALIZER, 1}
-#define BTHREAD_MUTEX_PRIORITY_2       {PTHREAD_MUTEX_INITIALIZER, 2}
-#define BTHREAD_MUTEX_PRIORITY_3       {PTHREAD_MUTEX_INITIALIZER, 3}
-#define BTHREAD_MUTEX_PRIORITY_4       {PTHREAD_MUTEX_INITIALIZER, 4}
 #define BTHREAD_MUTEX_INITIALIZER      BTHREAD_MUTEX_NO_PRIORITY
+
+/* Define USE_LOCKMGR_PRIORITY to detect mutex wrong order */
+#ifdef USE_LOCKMGR_PRIORITY
+# define BTHREAD_MUTEX_PRIORITY(p)      {PTHREAD_MUTEX_INITIALIZER, p}
+#else
+# define BTHREAD_MUTEX_PRIORITY(p)      BTHREAD_MUTEX_NO_PRIORITY
+#endif
+
 #define bthread_mutex_lock(x)      bthread_mutex_lock_p(x, __FILE__, __LINE__)
 #define bthread_mutex_unlock(x)    bthread_mutex_unlock_p(x, __FILE__, __LINE__)
 #define bthread_cond_wait(x,y)     bthread_cond_wait_p(x,y, __FILE__, __LINE__)
 #define bthread_cond_timedwait(x,y,z) bthread_cond_timedwait_p(x,y,z, __FILE__, __LINE__)
 
+/* 
+ * Define _LOCKMGR_COMPLIANT to use real pthread functions
+ */
+
 #ifdef _LOCKMGR_COMPLIANT
 # define P(x) lmgr_p(&(x))
 # define V(x) lmgr_v(&(x))
index 83df4ff07e179a9e91381d7131a60fd2116a229e..7ec359d2a3327324939a2506d05e797f082b9576 100644 (file)
 # ifndef _USE_LOCKMGR
 #  define _USE_LOCKMGR
 # endif
+/*
+ * Enable priority management with the lock manager
+ */
+//# define USE_LOCKMGR_PRIORITY
 #endif
 
 #if !HAVE_LINUX_OS