From 23392837f61fc878b87f5acb07d1a8cfb128b25d Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 16 Dec 2006 15:30:22 +0000 Subject: [PATCH] kes Implement cleaner orphan buffer dumping with buf address. 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 | 6 +++--- bacula/src/stored/acquire.c | 5 +++-- bacula/src/stored/append.c | 2 -- bacula/src/stored/job.c | 2 +- bacula/src/stored/reserve.c | 3 +-- bacula/src/stored/stored.c | 7 +++++++ bacula/technotes-1.39 | 2 ++ 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index 9ecb0039f8..f79c1c6c1e 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -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) { diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 7d423dc959..e673bd7669 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -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); } diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index b00c8119f1..6a57c14b47 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -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 */ diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 6002e45d41..891c4477b6 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -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; } diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index f9f8b33bb4..bf1bf3dfe7 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -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; } diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index e18ddee206..caa53f8a80 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -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(); diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 95833751d7..e85ed2cfbe 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -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 -- 2.39.5