]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Implement cleaner orphan buffer dumping with buf address.
authorKern Sibbald <kern@sibbald.com>
Sat, 16 Dec 2006 15:30:22 +0000 (15:30 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 16 Dec 2006 15:30:22 +0000 (15:30 +0000)
kes  Fix orphaned buffer when canceling job waiting on op intervention.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3806 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/lib/smartall.c
bacula/src/stored/acquire.c
bacula/src/stored/append.c
bacula/src/stored/job.c
bacula/src/stored/reserve.c
bacula/src/stored/stored.c
bacula/technotes-1.39

index 9ecb0039f83c74346e4904fd163482f449e8b229..f79c1c6c1e8426bf25cc560fbab2421496503e27 100644 (file)
@@ -388,16 +388,16 @@ void sm_dump(bool bufdump)
       if (ap->abfname != NULL) {
          unsigned memsize = ap->ablen - (HEAD_SIZE + 1);
          char errmsg[500];
+         char *cp = ((char *)ap) + HEAD_SIZE;
 
          bsnprintf(errmsg, sizeof(errmsg),
-           _("Orphaned buffer:  %6u bytes allocated at line %d of %s %s\n"),
-            memsize, ap->ablineno, my_name, ap->abfname
+           _("Orphaned buffer:  %s %6u bytes buf=%p allocated at %s:%d\n"),
+            my_name, memsize, cp, ap->abfname, ap->ablineno
          );
          fprintf(stderr, "%s", errmsg);
          if (bufdump) {
             char buf[20];
             unsigned llen = 0;
-            char *cp = ((char *) ap) + HEAD_SIZE;
 
             errmsg[0] = EOS;
             while (memsize) {
index 7d423dc959bd2a372ceed803a272b1665017a28f..e673bd7669d046d5f3286b38dbf037e68d0e210e 100644 (file)
@@ -641,6 +641,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 +653,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);
 }
index b00c8119f1c85da8399b5971248501c453019217..6a57c14b47cf0ddf5a8dc8d1533f629e0ef20af6 100644 (file)
@@ -83,7 +83,6 @@ bool do_append_data(JCR *jcr)
 
    if (!acquire_device_for_append(dcr)) {
       set_jcr_job_status(jcr, JS_ErrorTerminated);
-      jcr->dcr = NULL;
       return false;
    }
 
@@ -305,7 +304,6 @@ bool do_append_data(JCR *jcr)
    }
 
    if (!ok) {
-      Dmsg1(000, "Tape block=%d\n", dev->block_num);
       discard_data_spool(dcr);
    } else {
       /* Note: if commit is OK, the device will remain locked */
index 6002e45d41596136e4992952b701826dddb132a7..891c4477b69ad089af9e4f3a581196cb56b9d24e 100644 (file)
@@ -353,6 +353,7 @@ void stored_free_jcr(JCR *jcr)
       delete jcr->dcrs;
    }
    jcr->dcrs = NULL;
+
    if (jcr->dcr) {
       free_dcr(jcr->dcr);
       jcr->dcr = NULL;
@@ -380,6 +381,5 @@ void stored_free_jcr(JCR *jcr)
       delete jcr->write_store;
       jcr->write_store = NULL;
    }
-
    return;
 }
index f9f8b33bb44f5e8f7424970c17c8c4f73d79117c..bf1bf3dfe73003eed5d161afff03aefe3ea54f57 100644 (file)
@@ -308,7 +308,7 @@ void free_volume_list()
    }
    P(vol_list_lock);
    for (vol=(VOLRES *)vol_list->first(); vol; vol=(VOLRES *)vol_list->next(vol)) {
-      Dmsg3(000, "Unreleased Volume=%s dcr=0x%x dev=0x%x\n", vol->vol_name,
+      Dmsg3(100, "Unreleased Volume=%s dcr=0x%x dev=0x%x\n", vol->vol_name,
          vol->dcr, vol->dev);
    }
    delete vol_list;
@@ -604,7 +604,6 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx)
          break;
       }
    }
-
    return ok;
 }
 
index e18ddee206d8eac9e767c3b7a2f1d245a6361de5..caa53f8a80d6353f5dad44f35cd6f8e319de14b7 100644 (file)
@@ -510,6 +510,13 @@ void *device_initialization(void *arg)
       free_dcr(dcr);
       jcr->dcr = NULL;
    }
+#ifdef xxx
+   if (jcr->dcr) {
+      Dmsg1(000, "free_dcr=%p\n", jcr->dcr);
+      free_dcr(jcr->dcr);
+      jcr->dcr = NULL;
+   }
+#endif
    free_jcr(jcr); 
    init_done = true;
    UnlockRes();
index 95833751d72f0b7271f22a94357d4ff7d67b541b..e85ed2cfbe21d6a06168bb844a7460076afaf1ce 100644 (file)
@@ -2,6 +2,8 @@
 
 General:
 16Dec06
+kes  Implement cleaner orphan buffer dumping with buf address.
+kes  Fix orphaned buffer when canceling job waiting on op intervention.
 kes  Update projects file for next vote.
 kes  Implement a fix (more could be done) for bug #728 where a double
      EOF is writing on the Volume when spooling is enabled and the