]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/autochanger.c
Move reservations message lock to lock jcr only this
[bacula/bacula] / bacula / src / stored / autochanger.c
index dc6dae98c1a69a0b56149e4f6156773183fa175a..2edd3f66c31cba429a984fa2167b4390403af540 100644 (file)
@@ -7,8 +7,8 @@
    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 plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   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
@@ -197,10 +197,10 @@ int autoload_device(DCR *dcr, int writing, BSOCK *dir)
             berrno be;
             be.set_errno(status);
             Dmsg3(100, "load slot %d, drive %d, bad stats=%s.\n", slot, drive,
-               be.strerror());
+               be.bstrerror());
             Jmsg(jcr, M_FATAL, 0, _("3992 Bad autochanger \"load slot %d, drive %d\": "
                  "ERR=%s.\nResults=%s\n"),
-                    slot, drive, be.strerror(), results.c_str());
+                    slot, drive, be.bstrerror(), results.c_str());
             rtn_stat = -1;            /* hard error */
             dev->Slot = -1;           /* mark unknown */
          }
@@ -251,7 +251,7 @@ int get_autochanger_loaded_slot(DCR *dcr)
       return dev->Slot;
    }
    /* Virtual disk autochanger */
-   if (dcr->device->changer_command[0] ==0) {
+   if (dcr->device->changer_command[0] == 0) {
       return 1;
    }
 
@@ -280,7 +280,7 @@ int get_autochanger_loaded_slot(DCR *dcr)
       berrno be;
       be.set_errno(status);
       Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded? drive %d\" command: "
-           "ERR=%s.\nResults=%s\n"), drive, be.strerror(), results.c_str());
+           "ERR=%s.\nResults=%s\n"), drive, be.bstrerror(), results.c_str());
       loaded = -1;              /* force unload */
    }
    unlock_changer(dcr);
@@ -354,12 +354,13 @@ bool unload_autochanger(DCR *dcr, int loaded)
          be.set_errno(stat);
          Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": "
               "ERR=%s\nResults=%s\n"),
-                 loaded, dev->drive_index, be.strerror(), results.c_str());
+                 loaded, dev->drive_index, be.bstrerror(), results.c_str());
          ok = false;
          dev->Slot = -1;           /* unknown */
       } else {
          dev->Slot = 0;            /* nothing loaded */
       }
+      free_volume(dev);            /* Free any volume associated with this drive */
       free_pool_memory(changer);
       unlock_changer(dcr);
    }
@@ -380,7 +381,7 @@ static bool unload_other_drive(DCR *dcr, int slot)
    AUTOCHANGER *changer = dcr->dev->device->changer_res;
    DEVRES *device;
    bool found = false;
-   bool first = true;
+   int retries = 0;                /* wait for device retries */
 
    if (!changer) {
       return false;
@@ -408,8 +409,7 @@ static bool unload_other_drive(DCR *dcr, int slot)
    }   
    for (int i=0; i < 3; i++) {
       if (dev->is_busy()) {
-         wait_for_device(dcr->jcr, first);
-         first = false;
+         wait_for_device(dcr->jcr, retries);
          continue;
       }
       break;
@@ -452,16 +452,17 @@ static bool unload_other_drive(DCR *dcr, int slot)
       berrno be;
       be.set_errno(stat);
       Jmsg(jcr, M_INFO, 0, _("3995 Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n"),
-              slot, dev->drive_index, be.strerror());
+              slot, dev->drive_index, be.bstrerror());
 
       Dmsg3(100, "Bad autochanger \"unload slot %d, drive %d\": ERR=%s.\n",
-              slot, dev->drive_index, be.strerror());
+              slot, dev->drive_index, be.bstrerror());
       ok = false;
       dev->Slot = -1;          /* unknown */
    } else {
       dev->Slot = 0;           /* nothing loaded */
       Dmsg0(100, "Slot unloaded\n");
    }
+   free_volume(dev);               /* Free any volume associated with this drive */
    unlock_changer(dcr);
    dev->dunlock();
    free_pool_memory(changer_cmd);
@@ -541,7 +542,7 @@ bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd)
    if (stat != 0) {
       berrno be;
       be.set_errno(stat);
-      bnet_fsend(dir, _("Autochanger error: ERR=%s\n"), be.strerror());
+      bnet_fsend(dir, _("Autochanger error: ERR=%s\n"), be.bstrerror());
    }
    bnet_sig(dir, BNET_EOD);
    ok = true;