]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/reserve.c
Remove broken run when code
[bacula/bacula] / bacula / src / stored / reserve.c
index 2b7797b80162038e3eea43cb88a6c43f844bcf0b..7511c545762983a6d5dec5271aa1eaa234c64c7d 100644 (file)
@@ -86,7 +86,7 @@ void init_reservations_lock()
    if ((errstat=rwl_init(&reservation_lock)) != 0) {
       berrno be;
       Emsg1(M_ABORT, 0, _("Unable to initialize reservation lock. ERR=%s\n"),
-            be.strerror(errstat));
+            be.bstrerror(errstat));
    }
 
 }
@@ -106,7 +106,7 @@ void _lock_reservations()
    if ((errstat=rwl_writelock(&reservation_lock)) != 0) {
       berrno be;
       Emsg2(M_ABORT, 0, "rwl_writelock failure. stat=%d: ERR=%s\n",
-           errstat, be.strerror(errstat));
+           errstat, be.bstrerror(errstat));
    }
 }
 
@@ -117,7 +117,7 @@ void _unlock_reservations()
    if ((errstat=rwl_writeunlock(&reservation_lock)) != 0) {
       berrno be;
       Emsg2(M_ABORT, 0, "rwl_writeunlock failure. stat=%d: ERR=%s\n",
-           errstat, be.strerror(errstat));
+           errstat, be.bstrerror(errstat));
    }
 }
 
@@ -279,7 +279,6 @@ VOLRES *reserve_volume(DCR *dcr, const char *VolumeName)
     *  when adding a new volume that no newly scheduled
     *  job can reserve it.
     */
-// lock_reservations();
    P(vol_list_lock);
    debug_list_volumes("begin reserve_volume", debug_nolock);
    /* 
@@ -350,7 +349,6 @@ VOLRES *reserve_volume(DCR *dcr, const char *VolumeName)
 get_out:
    debug_list_volumes("end new volume", debug_nolock);
    V(vol_list_lock);
-// unlock_reservations();
    return vol;
 }
 
@@ -598,7 +596,7 @@ static bool use_storage_cmd(JCR *jcr)
     * Wiffle through them and find one that can do the backup.
     */
    if (ok) {
-      bool first = true;           /* print wait message once */
+      int retries = 0;                /* wait for device retries */
       bool fail = false;
       rctx.notify_dir = true;
       lock_reservations();
@@ -667,12 +665,11 @@ static bool use_storage_cmd(JCR *jcr)
          }
          /* Keep reservations locked *except* during wait_for_device() */
          unlock_reservations();
-         if (!rctx.suitable_device || !wait_for_device(jcr, first)) {
+         if (!rctx.suitable_device || !wait_for_device(jcr, retries)) {
             Dmsg0(100, "Fail. !suitable_device || !wait_for_device\n");
             fail = true;
          }   
          lock_reservations();
-         first = false;
          bnet_sig(dir, BNET_HEARTBEAT);  /* Inform Dir that we are alive */
       }
       unlock_reservations();
@@ -1083,15 +1080,17 @@ static int can_reserve_drive(DCR *dcr, RCTX &rctx)
       }
 
       /* Check for prefer mounted volumes */
-      if (rctx.PreferMountedVols && !dev->VolHdr.VolumeName[0] && dev->is_tape()) {
+//    if (rctx.PreferMountedVols && !dev->VolHdr.VolumeName[0] && dev->is_tape()) {
+      if (rctx.PreferMountedVols && !dev->vol && dev->is_tape()) {
          Mmsg(jcr->errmsg, _("3606 JobId=%u prefers mounted drives, but drive %s has no Volume.\n"), 
             jcr->JobId, dev->print_name());
          queue_reserve_message(jcr);
-         Dmsg1(110, "failed: want mounted -- no vol JobId=%u\n", jcr->JobId);
+         Dmsg1(110, "failed: want mounted -- no vol JobId=%u\n", (uint32_t)jcr->JobId);
          return 0;                 /* No volume mounted */
       }
 
       /* Check for exact Volume name match */
+      /*  ***FIXME***  use dev->vol.VolumeName */
       if (rctx.exact_match && rctx.have_volume &&
           strcmp(dev->VolHdr.VolumeName, rctx.VolumeName) != 0) {
          Mmsg(jcr->errmsg, _("3607 JobId=%u wants Vol=\"%s\" drive has Vol=\"%s\" on drive %s.\n"), 
@@ -1105,6 +1104,7 @@ static int can_reserve_drive(DCR *dcr, RCTX &rctx)
    }
 
    /* Check for unused autochanger drive */
+   /* ***FIXME*** use !dev->is_busy() */
    if (rctx.autochanger_only && dev->num_writers == 0 &&
        dev->VolHdr.VolumeName[0] == 0) {
       /* Device is available but not yet reserved, reserve it for us */