]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/acquire.c
kes Fix dird/ua_cmds.c so that a cancel command checks if the
[bacula/bacula] / bacula / src / stored / acquire.c
index 8aa0dd12be1b6573fc3555f39a943ce3216b66fc..69c8fa204974dcca0a62544272b6460269abbe2d 100644 (file)
@@ -8,7 +8,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -66,7 +66,7 @@ bool acquire_device_for_read(DCR *dcr)
    dev->block(BST_DOING_ACQUIRE);
 
    if (dev->num_writers > 0) {
-      Jmsg2(jcr, M_FATAL, 0, _("Num_writers=%d not zero. Job %d canceled.\n"), 
+      Jmsg2(jcr, M_FATAL, 0, _("Acquire read: num_writers=%d not zero. Job %d canceled.\n"), 
          dev->num_writers, jcr->JobId);
       goto get_out;
    }
@@ -75,7 +75,7 @@ bool acquire_device_for_read(DCR *dcr)
    vol = jcr->VolList;
    if (!vol) {
       char ed1[50];
-      Jmsg(jcr, M_FATAL, 0, _("No volumes specified. Job %s canceled.\n"), 
+      Jmsg(jcr, M_FATAL, 0, _("No volumes specified for reading. Job %s canceled.\n"), 
          edit_int64(jcr->JobId, ed1));
       goto get_out;
    }
@@ -84,7 +84,7 @@ bool acquire_device_for_read(DCR *dcr)
       vol = vol->next;
    }
    if (!vol) {
-      Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume. Numvol=%d Curvol=%d\n"),
+      Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"),
          jcr->NumReadVolumes, jcr->CurReadVolume);
       goto get_out;                   /* should not happen */   
    }
@@ -149,7 +149,7 @@ bool acquire_device_for_read(DCR *dcr)
          bstrncpy(dcr->pool_name, store->pool_name, sizeof(dcr->pool_name));
          bstrncpy(dcr->pool_type, store->pool_type, sizeof(dcr->pool_type));
       } else if (stat == 0) {   /* device busy */
-         Dmsg1(000, "Device %s is busy.\n", vol->device);
+         Pmsg1(000, "Device %s is busy.\n", vol->device);
       } else {
          /* error */
          Jmsg1(jcr, M_FATAL, 0, _("No suitable device found to read Volume \"%s\"\n"),
@@ -268,7 +268,7 @@ default_path:
       break;
    } /* end for loop */
    if (!ok) {
-      Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
+      Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s for reading.\n"),
             dev->print_name());
       goto get_out;
    }
@@ -321,8 +321,8 @@ DCR *acquire_device_for_append(DCR *dcr)
     * With the reservation system, this should not happen
     */
    if (dev->can_read()) {
-      Jmsg1(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev->print_name());
-      Dmsg1(200, "Device %s is busy reading.\n", dev->print_name());
+      Jmsg1(jcr, M_FATAL, 0, _("Want to append, but device %s is busy reading.\n"), dev->print_name());
+      Dmsg1(200, "Want to append but device %s is busy reading.\n", dev->print_name());
       goto get_out;
    }
 
@@ -351,9 +351,9 @@ DCR *acquire_device_for_append(DCR *dcr)
             free_unused_volume(dcr);
          }
          if (dev->num_writers != 0) {
-            Jmsg3(jcr, M_FATAL, 0, _("Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n"), 
+            Jmsg3(jcr, M_FATAL, 0, _("Wanted to append to Volume \"%s\", but device %s is busy writing on \"%s\" .\n"), 
                  dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName);
-            Dmsg3(200, "Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n",  
+            Dmsg3(200, "Wanted to append to Volume \"%s\", but device %s is busy writing on \"%s\" .\n",  
                  dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName);
             goto get_out;
          }
@@ -406,6 +406,8 @@ DCR *acquire_device_for_append(DCR *dcr)
    if (jcr->NumWriteVolumes == 0) {
       jcr->NumWriteVolumes = 1;
    }
+   dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs on vol */
+   dir_update_volume_info(dcr, false);        /* send Volume info to Director */
    P(dev->mutex);
    if (dcr->reserved_device) {
       dev->reserved_device--;
@@ -480,13 +482,12 @@ bool release_device(DCR *dcr)
                dcr->VolCatInfo.VolCatName, jcr->Job);
          }
          /* If no more writers, write an EOF */
-         if (!dev->num_writers && dev->can_write()) {
+         if (!dev->num_writers && dev->can_write() && dev->block_num > 0) {
             dev->weof(1);
             write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName);
          }
          if (!dev->at_weot()) {
             dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
-            dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
             /* Note! do volume update before close, which zaps VolCatInfo */
             Dmsg0(100, "dir_update_vol_info. Release0\n");
             dir_update_volume_info(dcr, false); /* send Volume info to Director */
@@ -641,6 +642,7 @@ void detach_dcr_from_dev(DCR *dcr)
  */
 void free_dcr(DCR *dcr)
 {
+   JCR *jcr = dcr->jcr;
 
    if (dcr->dev) {
       detach_dcr_from_dev(dcr);
@@ -652,8 +654,8 @@ void free_dcr(DCR *dcr)
    if (dcr->rec) {
       free_record(dcr->rec);
    }
-   if (dcr->jcr) {
-      dcr->jcr->dcr = NULL;
+   if (jcr && jcr->dcr == dcr) {
+      jcr->dcr = NULL;
    }
    free(dcr);
 }