]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/acquire.c
kes Apply Richard Mortimer's patches for printing an error
[bacula/bacula] / bacula / src / stored / acquire.c
index 9528f786c562748af04b009f7421e88501bca29f..50c79ebca28558738d4c1fb14975f32b4b602e3a 100644 (file)
@@ -47,6 +47,7 @@ bool acquire_device_for_read(DCR *dcr)
    bool try_autochanger = true;
    int i;
    int vol_label_status;
+   int retry = 0;
    
    Dmsg1(50, "jcr->dcr=%p\n", jcr->dcr);
    dev->block(BST_DOING_ACQUIRE);
@@ -87,6 +88,7 @@ bool acquire_device_for_read(DCR *dcr)
       int stat;
       DCR *dcr_save = jcr->dcr;
 
+      lock_reservations();
       jcr->dcr = NULL;
       memset(&rctx, 0, sizeof(RCTX));
       rctx.jcr = jcr;
@@ -108,6 +110,7 @@ bool acquire_device_for_read(DCR *dcr)
        */
       stat = search_res_for_device(rctx);
       release_msgs(jcr);              /* release queued messages */
+      unlock_reservations();
       if (stat == 1) {
          DCR *new_dcr = jcr->read_dcr;
          dev->unblock();
@@ -156,7 +159,11 @@ bool acquire_device_for_read(DCR *dcr)
       Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
    }
    
-   for (i=0; i<5; i++) {
+   for ( ;; ) {
+      /* If not polling limit retries */
+      if (!dev->poll && retry++ > 10) {
+         break;
+      }
       dev->clear_labeled();              /* force reread of label */
       if (job_canceled(jcr)) {
          Mmsg1(dev->errmsg, _("Job %d canceled.\n"), jcr->JobId);
@@ -205,6 +212,12 @@ bool acquire_device_for_read(DCR *dcr)
             tape_initially_mounted = false;
             goto default_path;
          }
+         /* If polling and got a previous bad name, ignore it */
+         if (dev->poll && strcmp(dev->BadVolName, dev->VolHdr.VolumeName) == 0) {
+            goto default_path;
+         } else {
+             bstrncpy(dev->BadVolName, dev->VolHdr.VolumeName, sizeof(dev->BadVolName));
+         }
          /* Fall through */
       default:
          Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
@@ -372,6 +385,7 @@ DCR *acquire_device_for_append(DCR *dcr)
          }
          goto get_out;
       }
+      Dmsg2(190, "Output pos=%u:%u\n", dcr->dev->file, dcr->dev->block_num);
    }
 
    dev->num_writers++;                /* we are now a writer */
@@ -447,7 +461,7 @@ bool release_device(DCR *dcr)
          }
          /* If no more writers, write an EOF */
          if (!dev->num_writers && dev->can_write()) {
-            weof_dev(dev, 1);
+            dev->weof(1);
             write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName);
          }
          if (!dev->at_weot()) {