From: Kern Sibbald Date: Fri, 11 Apr 2008 16:31:03 +0000 (+0000) Subject: kes Remove redundant code in terminating the scheduler that just X-Git-Tag: Release-3.0.0~1566 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a1b5e54fdb4c0af952732ad0831f2cca2baa8395;p=bacula%2Fbacula kes Remove redundant code in terminating the scheduler that just causes a seg fault in many cases. kes Cleanup releasing a volume and make it a DCR method. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6799 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/scheduler.c b/bacula/src/dird/scheduler.c index 0e888a7c12..1949b2dc65 100644 --- a/bacula/src/dird/scheduler.c +++ b/bacula/src/dird/scheduler.c @@ -118,6 +118,7 @@ JCR *wait_for_next_job(char *one_shot_job_to_run) return jcr; } } + /* Wait until we have something in the * next hour or so. */ @@ -246,11 +247,6 @@ again: void term_scheduler() { if (jobs_to_run) { - job_item *je; - /* Release all queued job entries to be run */ - foreach_dlist(je, jobs_to_run) { - free(je); - } delete jobs_to_run; } } @@ -285,7 +281,7 @@ static void find_runs() woy = tm_woy(now); /* get week of year */ Dmsg7(dbglvl, "now = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", - now, hour, month, mday, wday, wom, woy); + now, hour, month, mday, wday, wom, woy); /* * Compute values for next hour from now. @@ -303,7 +299,7 @@ static void find_runs() nh_woy = tm_woy(now); /* get week of year */ Dmsg7(dbglvl, "nh = %x: h=%d m=%d md=%d wd=%d wom=%d woy=%d\n", - next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy); + next_hour, nh_hour, nh_month, nh_mday, nh_wday, nh_wom, nh_woy); /* Loop through all jobs */ LockRes(); @@ -357,20 +353,20 @@ static void find_runs() Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh); - if (run_now || run_nh) { - /* find time (time_t) job is to be run */ - (void)localtime_r(&now, &tm); /* reset tm structure */ - tm.tm_min = run->minute; /* set run minute */ - tm.tm_sec = 0; /* zero secs */ - runtime = mktime(&tm); - if (run_now) { - add_job(job, run, now, runtime); - } - /* If job is to be run in the next hour schedule it */ - if (run_nh) { - add_job(job, run, now, runtime + 3600); - } - } + if (run_now || run_nh) { + /* find time (time_t) job is to be run */ + (void)localtime_r(&now, &tm); /* reset tm structure */ + tm.tm_min = run->minute; /* set run minute */ + tm.tm_sec = 0; /* zero secs */ + runtime = mktime(&tm); + if (run_now) { + add_job(job, run, now, runtime); + } + /* If job is to be run in the next hour schedule it */ + if (run_nh) { + add_job(job, run, now, runtime + 3600); + } + } } } UnlockRes(); diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index c57a49fcd2..edb13c7e39 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -473,12 +473,14 @@ public: /* Methods in mount.c */ bool mount_next_write_volume(); + bool mount_next_read_volume(); void mark_volume_in_error(); void mark_volume_not_inchanger(); int try_autolabel(bool opened); bool is_suitable_volume_mounted(); bool is_eod_valid(); int check_volume_label(bool &ask, bool &autochanger); + void release_volume(); }; /* diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index a7b631a831..411d6687a3 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -915,7 +915,7 @@ static bool release_cmd(JCR *jcr) } else { /* device not being used */ Dmsg0(90, "Device not in use, releaseing\n"); unload_autochanger(dcr, -1); - release_volume(dcr); + dcr->release_volume(); dir->fsend(_("3022 Device %s released.\n"), dev->print_name()); } diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 1edab43492..4969a9bb70 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -102,8 +102,8 @@ mount_next_vol: recycle = false; if (unload_device) { Dmsg0(150, "mount_next_volume release=1\n"); - release_volume(dcr); unload_autochanger(dcr, -1); + release_volume(); unload_device = false; ask = true; /* ask operator to mount tape */ } @@ -636,11 +636,9 @@ void DCR::mark_volume_not_inchanger() * Either because we are going to hang a new volume, or because * of explicit user request, we release the current volume. */ -void release_volume(DCR *dcr) +void DCR::release_volume() { - JCR *jcr = dcr->jcr; - DEVICE *dev = dcr->dev; - if (dcr->WroteVol) { + if (WroteVol) { Jmsg0(jcr, M_ERROR, 0, _("Hey!!!!! WroteVol non-zero !!!!!\n")); Dmsg0(190, "Hey!!!!! WroteVol non-zero !!!!!\n"); } @@ -651,14 +649,14 @@ void release_volume(DCR *dcr) dev->block_num = dev->file = 0; dev->EndBlock = dev->EndFile = 0; memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo)); -// memset(&dcr->VolCatInfo, 0, sizeof(dcr->VolCatInfo)); + memset(&VolCatInfo, 0, sizeof(VolCatInfo)); dev->clear_volhdr(); /* Force re-read of label */ dev->clear_labeled(); dev->clear_read(); dev->clear_append(); dev->label_type = B_BACULA_LABEL; -// dcr->VolumeName[0] = 0; + VolumeName[0] = 0; if (dev->is_open() && (!dev->is_tape() || !dev->has_cap(CAP_ALWAYSOPEN))) { dev->close(); diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 490355a337..ef8ebc09f8 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -218,7 +218,6 @@ void _lock_reservations(); void _unlock_reservations(); void _lock_volumes(); void _unlock_volumes(); -void release_volume(DCR *dcr); VOLRES *reserve_volume(DCR *dcr, const char *VolumeName); VOLRES *find_volume(const char *VolumeName); bool free_volume(DEVICE *dev); diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index fa0415574b..e19ebe7860 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -25,6 +25,9 @@ Add long term statistics job table General: 11Apr08 +kes Remove redundant code in terminating the scheduler that just + causes a seg fault in many cases. +kes Cleanup releasing a volume and make it a DCR method. kes Improve algorithm for detecting pre-reserved volume and swapping volumes. 10Apr08