* Define _LOCKMGR_COMPLIANT to use real pthread functions
*/
-#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 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 bthread_mutex_lock(x) bthread_mutex_lock_p(x, __FILE__, __LINE__)
-#define bthread_mutex_unlock(x) bthread_mutex_unlock_p
+#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 lmgr_do_unlock(m)
# define lmgr_cleanup_main()
# define bthread_mutex_set_priority(a)
-# define bthread_mutex_lock(a) pthread_mutex_lock(a)
-# define bthread_mutex_unlock(a) pthread_mutex_unlock(a)
-# define lmgr_cond_wait(a,b) pthread_cond_wait(a,b)
-# define lmgr_cond_timedwait(a,b,c) pthread_cond_timedwait(a,b,c)
-# define bthread_mutex_t pthread_mutex_t
+# define bthread_mutex_lock(a) pthread_mutex_lock(a)
+# define bthread_mutex_unlock(a) pthread_mutex_unlock(a)
+# define lmgr_cond_wait(a,b) pthread_cond_wait(a,b)
+# define lmgr_cond_timedwait(a,b,c) pthread_cond_timedwait(a,b,c)
+# define bthread_mutex_t pthread_mutex_t
# define P(x) lmgr_p(&(x))
# define V(x) lmgr_v(&(x))
-# define BTHREAD_MUTEX_NO_PRIORITY PTHREAD_MUTEX_INITIALIZER
-# define BTHREAD_MUTEX_PRIORITY_1 PTHREAD_MUTEX_INITIALIZER
-# define BTHREAD_MUTEX_PRIORITY_2 PTHREAD_MUTEX_INITIALIZER
-# define BTHREAD_MUTEX_PRIORITY_3 PTHREAD_MUTEX_INITIALIZER
-# define BTHREAD_MUTEX_PRIORITY_4 PTHREAD_MUTEX_INITIALIZER
-# define BTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_PRIORITY(p) PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_NO_PRIORITY PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_PRIORITY_1 PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_PRIORITY_2 PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_PRIORITY_3 PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_PRIORITY_4 PTHREAD_MUTEX_INITIALIZER
+# define BTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif /* _USE_LOCKMGR */
+#include "mutex_list.h" /* Manage mutex with priority in a central place */
+
#endif /* _LOCKMGR_H */
--- /dev/null
+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2009-2009 Free Software Foundation Europe e.V.
+
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation, which is
+ listed in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of Kern Sibbald.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
+
+#ifndef MUTEX_LIST_H
+#define MUTEX_LIST_H 1
+
+/*
+ * Use this list to manage lock order and protect the Bacula from
+ * race conditions and dead locks
+ */
+
+#define PRIO_SD_VOLUME_LIST 20
+#define PRIO_SD_DEV_ACCESS 15
+#define PRIO_SD_DEV_SPOOL 14
+#define PRIO_SD_DEV_ACQUIRE 13
+
+#endif