From 07a51b7e5cae75c1a82011f06abfaf9f9bc7374b Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 7 Dec 2009 18:18:03 +0100 Subject: [PATCH] Small tweaks to locking code no substantial change --- bacula/src/stored/acquire.c | 1 - bacula/src/stored/lock.c | 11 +++++++---- bacula/src/stored/protos.h | 1 - bacula/src/stored/vol_mgr.c | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 7623702a34..c1962e1aba 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -511,7 +511,6 @@ bool release_device(DCR *dcr) unlock_volumes(); Dmsg3(100, "%d writers, %d reserve, dev=%s\n", dev->num_writers, dev->num_reserved(), dev->print_name()); - debug_list_volumes("acquire:release_device()"); /* If no writers, close if file or !CAP_ALWAYS_OPEN */ diff --git a/bacula/src/stored/lock.c b/bacula/src/stored/lock.c index 392eab47a1..7270773593 100644 --- a/bacula/src/stored/lock.c +++ b/bacula/src/stored/lock.c @@ -55,12 +55,14 @@ const int dbglvl = 500; * 2. dlock() simple mutex that locks the device structure. A dlock * can be acquired while a device is blocked if it is not * locked. - * 3. r_dlock "recursive" dlock, when means that a dlock (mutex) + * 3. r_dlock(locked) "recursive" dlock, when means that a dlock (mutex) * will be acquired on the device if it is not blocked * by some other thread. If the device was blocked by * the current thread, it will acquire the lock. * If some other thread has set a block on the device, * this call will wait until the device is unblocked. + * Can be called with locked true, which means the + * dlock is already set * * A lock is normally set when modifying the device structure. * A r_lock is normally acquired when you want to block the device @@ -88,9 +90,10 @@ const int dbglvl = 500; * DEVICE::dlock() does P(m_mutex) (in dev.h) * DEVICE::dunlock() does V(m_mutex) * - * DEVICE::r_dlock() allows locking the device when this thread - already has the device blocked. - * dlock() + * DEVICE::r_dlock(locked) allows locking the device when this thread + * already has the device blocked. + * if (!locked) + * dlock() * if blocked and not same thread that locked * pthread_cond_wait * leaves device locked diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 862a5523a5..8aa28538e5 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -278,7 +278,6 @@ void create_volume_lists(); void free_volume_lists(); void list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg); bool is_volume_in_use(DCR *dcr); -void debug_list_volumes(const char *imsg); extern int vol_list_lock_count; void add_read_volume(JCR *jcr, const char *VolumeName); void remove_read_volume(JCR *jcr, const char *VolumeName); diff --git a/bacula/src/stored/vol_mgr.c b/bacula/src/stored/vol_mgr.c index 55b7001e8b..61b2c9fbb7 100644 --- a/bacula/src/stored/vol_mgr.c +++ b/bacula/src/stored/vol_mgr.c @@ -49,6 +49,7 @@ static pthread_mutex_t read_vol_lock = PTHREAD_MUTEX_INITIALIZER; /* Forward referenced functions */ static void free_vol_item(VOLRES *vol); static VOLRES *new_vol_item(DCR *dcr, const char *VolumeName); +static void debug_list_volumes(const char *imsg); /* * For append volumes the key is the VolumeName. @@ -195,7 +196,7 @@ enum { debug_nolock = false }; -void debug_list_volumes(const char *imsg) +static void debug_list_volumes(const char *imsg) { VOLRES *vol; POOL_MEM msg(PM_MESSAGE); -- 2.39.5