From c8ea6cb50f4d6b1d78a0635b19086db3151bba29 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 14 Aug 2009 11:50:53 +0200 Subject: [PATCH] Fix acquire.c locking --- bacula/src/stored/acquire.c | 3 ++- bacula/src/stored/dev.h | 4 ++-- bacula/src/stored/lock.c | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 2180ebb4f3..b15c954daa 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -386,8 +386,9 @@ DCR *acquire_device_for_append(DCR *dcr) } if (!have_vol) { + dev->r_dlock(true); + block_device(dev, BST_DOING_ACQUIRE); dev->dunlock(); - dev->dblock(BST_DOING_ACQUIRE); Dmsg1(190, "jid=%u Do mount_next_write_vol\n", (uint32_t)jcr->JobId); if (!dcr->mount_next_write_volume()) { if (!job_canceled(jcr)) { diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 052015e23f..51a1b1b6ae 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -443,12 +443,12 @@ public: * Locking and blocking calls */ #ifdef SD_DEBUG_LOCK - void _r_dlock(const char *, int); /* in lock.c */ + void _r_dlock(const char *, int, bool locked=false); /* in lock.c */ void _r_dunlock(const char *, int); /* in lock.c */ void _dlock(const char *, int); /* in lock.c */ void _dunlock(const char *, int); /* in lock.c */ #else - void r_dlock(); /* in lock.c */ + void r_dlock(bool locked=false); /* in lock.c */ void r_dunlock() { dunlock(); } void dlock() { P(m_mutex); } void dunlock() { V(m_mutex); } diff --git a/bacula/src/stored/lock.c b/bacula/src/stored/lock.c index a1e7aa69b6..392eab47a1 100644 --- a/bacula/src/stored/lock.c +++ b/bacula/src/stored/lock.c @@ -206,17 +206,19 @@ void DEVICE::_r_dunlock(const char *file, int line) * and preparing the label. */ #ifdef SD_DEBUG_LOCK -void DEVICE::_r_dlock(const char *file, int line) +void DEVICE::_r_dlock(const char *file, int line, bool locked) { Dmsg3(sd_dbglvl+1, "r_dlock blked=%s from %s:%d\n", this->print_blocked(), file, line); #else -void DEVICE::r_dlock() +void DEVICE::r_dlock(bool locked) { #endif int stat; - P(m_mutex); /* this->dlock(); */ - m_count++; /* this->dlock() */ + if (!locked) { + P(m_mutex); /* this->dlock(); */ + m_count++; /* this->dlock() */ + } if (this->blocked() && !pthread_equal(this->no_wait_id, pthread_self())) { this->num_waiting++; /* indicate that I am waiting */ while (this->blocked()) { -- 2.39.5