From d420a874884f526a4500062e74680bef76dddc06 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 15 Sep 2009 11:01:37 -0700 Subject: [PATCH] more job-restart code --- bacula/src/dird/jobq.c | 3 +-- bacula/src/dird/msgchan.c | 6 ++--- bacula/src/jcr.h | 1 + bacula/src/stored/job.c | 46 +++++++++++++++++++++++++-------------- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 8e93945ac9..e5db9c46d8 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2003-2008 Free Software Foundation Europe e.V. + Copyright (C) 2003-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -37,7 +37,6 @@ * * Kern Sibbald, July MMIII * - * Version $Id$ * * This code was adapted from the Bacula workq, which was * adapted from "Programming with POSIX Threads", by diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 0305056713..2c9065f1dd 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2008 Free Software Foundation Europe e.V. + Copyright (C) 2000-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -40,7 +40,6 @@ * Create a thread to interact with the Storage daemon * who returns a job status and requests Catalog services, etc. * - * Version $Id$ */ #include "bacula.h" @@ -51,7 +50,8 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* Commands sent to Storage daemon */ static char jobcmd[] = "JobId=%s job=%s job_name=%s client_name=%s " "type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s " - "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d SpoolSize=%s\n"; + "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d SpoolSize=%s " + "Resched=%d\n"; static char use_storage[] = "use storage=%s media_type=%s pool_name=%s " "pool_type=%s append=%d copy=%d stripe=%d\n"; static char use_device[] = "use device=%s\n"; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 8513fe6d44..2700e2d447 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -414,6 +414,7 @@ public: alist *reserve_msgs; /* reserve fail messages */ bool write_part_after_job; /* Set to write part after job */ bool PreferMountedVols; /* Prefer mounted vols rather than new */ + bool Resched; /* Job may be rescheduled */ /* Parmaters for Open Read Session */ BSR *bsr; /* Bootstrap record -- has everything */ diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 4bb402fc4e..af54c51656 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -30,8 +30,6 @@ * * Kern Sibbald, MM * - * Version $Id$ - * */ #include "bacula.h" @@ -47,10 +45,15 @@ extern uint32_t newVolSessionId(); extern bool do_mac(JCR *jcr); /* Requests from the Director daemon */ +/* Added in 3.1.4 14Sep09 KES */ static char jobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s " "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s " - "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d SpoolSize=%s\n"; + "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d SpoolSize=%s " + "Resched=%d\n"; static char oldjobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s " + "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s " + "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d SpoolSize=%s\n"; +static char oldoldjobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s " "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s " "SpoolData=%d WritePartAfterJob=%d PreferMountedVols=%d\n"; @@ -83,6 +86,7 @@ bool job_cmd(JCR *jcr) POOL_MEM job_name, client_name, job, fileset_name, fileset_md5; int JobType, level, spool_attributes, no_attributes, spool_data; int write_part_after_job, PreferMountedVols; + int Resched = 0; int stat; JCR *ojcr; @@ -95,20 +99,29 @@ bool job_cmd(JCR *jcr) client_name.c_str(), &JobType, &level, fileset_name.c_str(), &no_attributes, &spool_attributes, fileset_md5.c_str(), &spool_data, - &write_part_after_job, &PreferMountedVols, spool_size); - if (stat != 14) { + &write_part_after_job, &PreferMountedVols, spool_size, + Resched); + if (stat != 15) { /* Try old version */ - stat = sscanf(dir->msg, oldjobcmd, &JobId, job.c_str(), job_name.c_str(), - client_name.c_str(), - &JobType, &level, fileset_name.c_str(), &no_attributes, - &spool_attributes, fileset_md5.c_str(), &spool_data, - &write_part_after_job, &PreferMountedVols); - if (stat != 13) { - pm_strcpy(jcr->errmsg, dir->msg); - dir->fsend(BAD_job, stat, jcr->errmsg); - Dmsg1(100, ">dird: %s", dir->msg); - set_jcr_job_status(jcr, JS_ErrorTerminated); - return false; + stat = sscanf(dir->msg, jobcmd, &JobId, job.c_str(), job_name.c_str(), + client_name.c_str(), + &JobType, &level, fileset_name.c_str(), &no_attributes, + &spool_attributes, fileset_md5.c_str(), &spool_data, + &write_part_after_job, &PreferMountedVols, spool_size); + if (stat != 14) { + /* Try oldold version */ + stat = sscanf(dir->msg, oldoldjobcmd, &JobId, job.c_str(), job_name.c_str(), + client_name.c_str(), + &JobType, &level, fileset_name.c_str(), &no_attributes, + &spool_attributes, fileset_md5.c_str(), &spool_data, + &write_part_after_job, &PreferMountedVols); + if (stat != 13) { + pm_strcpy(jcr->errmsg, dir->msg); + dir->fsend(BAD_job, stat, jcr->errmsg); + Dmsg1(100, ">dird: %s", dir->msg); + set_jcr_job_status(jcr, JS_ErrorTerminated); + return false; + } } } /* @@ -145,6 +158,7 @@ bool job_cmd(JCR *jcr) pm_strcpy(jcr->fileset_md5, fileset_md5); jcr->PreferMountedVols = PreferMountedVols; + jcr->authenticated = false; /* -- 2.39.5