]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix acquire.c locking
authorKern Sibbald <kern@sibbald.com>
Fri, 14 Aug 2009 09:50:53 +0000 (11:50 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 15 Aug 2009 19:37:37 +0000 (21:37 +0200)
bacula/src/stored/acquire.c
bacula/src/stored/dev.h
bacula/src/stored/lock.c

index 2180ebb4f39f46f3139f6804bbf209681efc25c0..b15c954daaabac21f4fb7a17e4271cd13413bb86 100644 (file)
@@ -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)) {
index 052015e23f2b81d6b673b9cca3e9a34611ea1812..51a1b1b6ae688ad5a1e9a0389f0b5ac9e7e2cac6 100644 (file)
@@ -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); } 
index a1e7aa69b60261619867d4063327480d94c9e7fd..392eab47a148a7a40f91c5f2fe6ffab790c7ddf1 100644 (file)
@@ -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()) {