From: Kern Sibbald Date: Mon, 7 Dec 2009 17:18:03 +0000 (+0100) Subject: Small tweaks to locking code no substantial change X-Git-Tag: Release-3.0.3b~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c23aaedd9df60a88f1eec5e60da67b395bed9791;p=bacula%2Fbacula Small tweaks to locking code no substantial change --- diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 70424402e0..dead10b022 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -498,7 +498,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 aea4b6a203..ecb2d0ac90 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 526d59fa1c..e28f1794de 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -282,7 +282,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 0d6b088912..2836c82269 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);