From 15f10308b46638aaf5b8f93d42ebbc55e29642ba Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 8 Feb 2008 11:19:28 +0000 Subject: [PATCH] kes Apply patch from Peter Much that fixes a resource embedded run command to find a since time if no explicit since time was supplied on the command line. kes Apply state-file.patch sent by Allan Black that updates the state file at job termination time in addition to when the daemon terminates. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6377 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/AUTHORS | 2 + bacula/src/dird/fd_cmds.c | 10 ++--- bacula/src/dird/job.c | 4 ++ bacula/src/filed/job.c | 3 ++ bacula/src/lib/jcr.c | 88 ++++++++++++++++++++------------------- bacula/src/stored/job.c | 4 ++ bacula/src/version.h | 4 +- bacula/technotes-2.3 | 7 ++++ 8 files changed, 73 insertions(+), 49 deletions(-) diff --git a/bacula/AUTHORS b/bacula/AUTHORS index f188694af8..79964805d0 100644 --- a/bacula/AUTHORS +++ b/bacula/AUTHORS @@ -15,6 +15,7 @@ Aitor Matilla Aleksandar Milivojevic Alexander Bergolth Alexandre Baron +Allan Black Andreas Piesk Andrew Ford Arno Lehmann @@ -72,6 +73,7 @@ Nicolas Boichat Olivier Lehmann Peter Buschmann Peter Eriksson +Peter Much Philippe Chauvat Phil Stracchino Preben Guldberg diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 6c032fb54f..ffe312c16d 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -163,13 +163,13 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) int JobLevel; since[0] = 0; - if (jcr->cloned) { - if (jcr->stime && jcr->stime[0]) { - bstrncpy(since, _(", since="), since_len); - bstrncat(since, jcr->stime, since_len); - } + /* If job cloned and a since time already given, use it */ + if (jcr->cloned && jcr->stime && jcr->stime[0]) { + bstrncpy(since, _(", since="), since_len); + bstrncat(since, jcr->stime, since_len); return; } + /* Make sure stime buffer is allocated */ if (!jcr->stime) { jcr->stime = get_pool_memory(PM_MESSAGE); } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index a66ef0cdae..15beadf273 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -892,6 +892,10 @@ void dird_free_jcr(JCR *jcr) free_rwstorage(jcr); jcr->job_end_push.destroy(); + + if (jcr->JobId != 0) + write_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); + Dmsg0(200, "End dird free_jcr\n"); } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 5673a633cc..7ee5cb826d 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1797,6 +1797,9 @@ static void filed_free_jcr(JCR *jcr) free_runscripts(jcr->RunScripts); delete jcr->RunScripts; + if (jcr->JobId != 0) + write_state_file(me->working_directory, "bacula-fd", get_first_port_host_order(me->FDaddrs)); + return; } diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index ae4e40e9ec..b193fcbfcc 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -336,47 +336,6 @@ static void remove_jcr(JCR *jcr) */ static void free_common_jcr(JCR *jcr) { - struct s_last_job *je, last_job; - - /* Keep some statistics */ - switch (jcr->JobType) { - case JT_BACKUP: - case JT_VERIFY: - case JT_RESTORE: - case JT_MIGRATE: - case JT_COPY: - case JT_ADMIN: - num_jobs_run++; - last_job.Errors = jcr->Errors; - last_job.JobType = jcr->JobType; - last_job.JobId = jcr->JobId; - last_job.VolSessionId = jcr->VolSessionId; - last_job.VolSessionTime = jcr->VolSessionTime; - bstrncpy(last_job.Job, jcr->Job, sizeof(last_job.Job)); - last_job.JobFiles = jcr->JobFiles; - last_job.JobBytes = jcr->JobBytes; - last_job.JobStatus = jcr->JobStatus; - last_job.JobLevel = jcr->JobLevel; - last_job.start_time = jcr->start_time; - last_job.end_time = time(NULL); - /* Keep list of last jobs, but not Console where JobId==0 */ - if (last_job.JobId > 0) { - je = (struct s_last_job *)malloc(sizeof(struct s_last_job)); - memcpy((char *)je, (char *)&last_job, sizeof(last_job)); - if (!last_jobs) { - init_last_jobs_list(); - } - last_jobs->append(je); - if (last_jobs->size() > max_last_jobs) { - je = (struct s_last_job *)last_jobs->first(); - last_jobs->remove(je); - free(je); - } - } - break; - default: - break; - } jcr->destroy_mutex(); if (jcr->msg_queue) { @@ -446,12 +405,15 @@ static void free_common_jcr(JCR *jcr) #ifdef DEBUG void b_free_jcr(const char *file, int line, JCR *jcr) { + struct s_last_job *je, last_job; + Dmsg3(dbglvl, "Enter free_jcr jid=%u from %s:%d\n", jcr->JobId, file, line); #else void free_jcr(JCR *jcr) { + struct s_last_job *je, last_job; Dmsg3(dbglvl, "Enter free_jcr jid=%u use_count=%d Job=%s\n", jcr->JobId, jcr->use_count(), jcr->Job); @@ -478,14 +440,56 @@ void free_jcr(JCR *jcr) jcr->JobId, jcr->use_count(), jcr->Job); } remove_jcr(jcr); /* remove Jcr from chain */ - unlock_jcr_chain(); job_end_pop(jcr); /* pop and call hooked routines */ Dmsg1(dbglvl, "End job=%d\n", jcr->JobId); + + /* Keep some statistics */ + switch (jcr->JobType) { + case JT_BACKUP: + case JT_VERIFY: + case JT_RESTORE: + case JT_MIGRATE: + case JT_COPY: + case JT_ADMIN: + num_jobs_run++; + last_job.Errors = jcr->Errors; + last_job.JobType = jcr->JobType; + last_job.JobId = jcr->JobId; + last_job.VolSessionId = jcr->VolSessionId; + last_job.VolSessionTime = jcr->VolSessionTime; + bstrncpy(last_job.Job, jcr->Job, sizeof(last_job.Job)); + last_job.JobFiles = jcr->JobFiles; + last_job.JobBytes = jcr->JobBytes; + last_job.JobStatus = jcr->JobStatus; + last_job.JobLevel = jcr->JobLevel; + last_job.start_time = jcr->start_time; + last_job.end_time = time(NULL); + /* Keep list of last jobs, but not Console where JobId==0 */ + if (last_job.JobId > 0) { + je = (struct s_last_job *)malloc(sizeof(struct s_last_job)); + memcpy((char *)je, (char *)&last_job, sizeof(last_job)); + if (!last_jobs) { + init_last_jobs_list(); + } + last_jobs->append(je); + if (last_jobs->size() > max_last_jobs) { + je = (struct s_last_job *)last_jobs->first(); + last_jobs->remove(je); + free(je); + } + } + break; + default: + break; + + } if (jcr->daemon_free_jcr) { jcr->daemon_free_jcr(jcr); /* call daemon free routine */ } + + unlock_jcr_chain(); free_common_jcr(jcr); close_msg(NULL); /* flush any daemon messages */ garbage_collect_memory_pool(); diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index e18d41c7ee..c3fc476925 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -406,5 +406,9 @@ void stored_free_jcr(JCR *jcr) jcr->write_store = NULL; } Dsm_check(1); + + if (jcr->JobId != 0) + write_state_file(me->working_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); + return; } diff --git a/bacula/src/version.h b/bacula/src/version.h index dce0a134c7..8ccd5d54b4 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.9" -#define BDATE "05 February 2008" -#define LSMDATE "05Feb08" +#define BDATE "08 February 2008" +#define LSMDATE "08Feb08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index a021105308..885bb69fad 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,13 @@ Technical notes on version 2.3 General: +08Feb08 +kes Apply patch from Peter Much that fixes + a resource embedded run command to find a since time if no explicit + since time was supplied on the command line. +kes Apply state-file.patch sent by Allan Black + that updates the state file at job termination time in addition to + when the daemon terminates. 05Feb08 kes First version where a plugin did a backup. bpipe-fd.so created a backup file, wrote a test -- 2.39.5