]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/read_record.c
added WSACleanup(), corrected WSA_Init() (removed #ifdef)
[bacula/bacula] / bacula / src / stored / read_record.c
index 6b9a177d87e34ec0878effd360660b2623b02739..64a3d6e49c9abe840cadac72516a29ce4eb5ab7a 100644 (file)
@@ -66,7 +66,7 @@ int read_records(JCR *jcr,  DEVICE *dev,
         if (dev_state(dev, ST_EOT)) {
            DEV_RECORD *trec = new_record();
 
-            Jmsg(jcr, M_INFO, 0, "End of Volume at file %u  on device %s, Volume \"%s\"\n", 
+            Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n", 
                 dev->file, dev_name(dev), jcr->VolumeName);
            if (!mount_cb(jcr, dev, block)) {
                Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
@@ -105,18 +105,22 @@ int read_records(JCR *jcr,  DEVICE *dev,
                  dev->file, dev_name(dev), jcr->VolumeName);
            continue;
         } else if (dev_state(dev, ST_SHORT)) {
-            Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
+            Jmsg1(jcr, M_ERROR, 0, "%s", dev->errmsg);
            continue;
         } else {
            /* I/O error or strange end of tape */
            display_tape_error_status(jcr, dev);
+           if (forge_on || jcr->ignore_label_errors) {
+              fsr_dev(dev, 1);       /* try skipping bad record */
+               Dmsg0(000, "Did fsr\n");
+              continue;              /* try to continue */
+           }
            ok = FALSE;
            break;
         }
       }
       Dmsg2(100, "New block at position=(file:block) %d:%d\n", dev->file, dev->block_num);
-#define FAST_BLOCK_REJECTION
-#ifdef FAST_BLOCK_REJECTION
+#ifdef if_and_when_FAST_BLOCK_REJECTION_is_working
       /* this does not stop when file/block are too big */
       if (!match_bsr_block(jcr->bsr, block)) {
         if (try_repositioning(jcr, rec, dev)) {
@@ -131,7 +135,7 @@ int read_records(JCR *jcr,  DEVICE *dev,
        *   VolSessionId and VolSessionTime 
        */
       bool found = false;
-      for (rec=(DEV_RECORD *)recs->first(); rec; rec=(DEV_RECORD *)recs->next(rec)) {
+      foreach_dlist(rec, recs) {
         if (rec->VolSessionId == block->VolSessionId &&
             rec->VolSessionTime == block->VolSessionTime) {
            found = true;
@@ -237,14 +241,13 @@ int read_records(JCR *jcr,  DEVICE *dev,
 // Dmsg2(100, "Position=(file:block) %d:%d\n", dev->file, dev->block_num);
 
    /* Walk down list and free all remaining allocated recs */
-   for (rec=(DEV_RECORD *)recs->first(); rec; ) {
-      DEV_RECORD *nrec = (DEV_RECORD *)recs->next(rec);
+   while (!recs->empty()) {
+      rec = (DEV_RECORD *)recs->first();
       recs->remove(rec);
       free_record(rec);
-      rec = nrec;
    }
    delete recs;
-   print_block_errors(jcr, block);
+   print_block_read_errors(jcr, block);
    free_block(block);
    return ok;
 }
@@ -268,7 +271,7 @@ static int try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev)
       return 1;
    }    
    if (bsr) {
-      if (verbose > 1) {
+      if (verbose) {
          Jmsg(jcr, M_INFO, 0, "Reposition from (file:block) %d:%d to %d:%d\n",
            dev->file, dev->block_num, bsr->volfile->sfile,
            bsr->volblock->sblock);
@@ -345,19 +348,19 @@ static char *rec_state_to_str(DEV_RECORD *rec)
    static char buf[200]; 
    buf[0] = 0;
    if (rec->state & REC_NO_HEADER) {
-      strcat(buf, "Nohdr,");
+      bstrncat(buf, "Nohdr,", sizeof(buf));
    }
    if (is_partial_record(rec)) {
-      strcat(buf, "partial,");
+      bstrncat(buf, "partial,", sizeof(buf));
    }
    if (rec->state & REC_BLOCK_EMPTY) {
-      strcat(buf, "empty,");
+      bstrncat(buf, "empty,", sizeof(buf));
    }
    if (rec->state & REC_NO_MATCH) {
-      strcat(buf, "Nomatch,");
+      bstrncat(buf, "Nomatch,", sizeof(buf));
    }
    if (rec->state & REC_CONTINUATION) {
-      strcat(buf, "cont,");
+      bstrncat(buf, "cont,", sizeof(buf));
    }
    if (buf[0]) {
       buf[strlen(buf)-1] = 0;