From 7706b7d23664a13284f2f2c567ff17f5d34abd21 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 29 Sep 2008 07:55:36 +0000 Subject: [PATCH] kes Create plugin instance only when FD job starts. kes Add new FD plugin event: bEventCancelCommand when a cancel command is issued to the FD git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7661 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/LICENSE | 2 +- bacula/src/filed/fd_plugins.h | 1 + bacula/src/filed/job.c | 4 ++-- bacula/src/lib/jcr.c | 11 ++++++++--- bacula/src/version.h | 6 +++--- bacula/technotes-2.5 | 4 ++++ 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bacula/LICENSE b/bacula/LICENSE index 3588de3fd2..1e49d53535 100644 --- a/bacula/LICENSE +++ b/bacula/LICENSE @@ -5,7 +5,7 @@ the copyright was transferred to the Free Software Foundation Europe on 15 November 2006. Trademark: -The name Bacula is a registered trademark. +The name Bacula is a registered trademark of Kern Sibbald. =================================== diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index 0370ee29e7..0ca7b878b3 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -159,6 +159,7 @@ typedef enum { bEventRestoreCommand = 10, bEventLevel = 11, bEventSince = 12, + bEventCancelCommand = 13, } bEventType; typedef struct s_bEvent { diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 98f7318184..b85b148fe3 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -214,7 +214,6 @@ void *handle_client_request(void *dirp) jcr->last_fname = get_pool_memory(PM_FNAME); jcr->last_fname[0] = 0; jcr->client_name = get_memory(strlen(my_name) + 1); - new_plugins(jcr); /* instantiate plugins for this jcr */ pm_strcpy(jcr->client_name, my_name); jcr->crypto.pki_sign = me->pki_sign; jcr->crypto.pki_encrypt = me->pki_encrypt; @@ -227,7 +226,6 @@ void *handle_client_request(void *dirp) /**********FIXME******* add command handler error code */ for (quit=false; !quit;) { - /* Read command */ if (dir->recv() < 0) { break; /* connection terminated */ @@ -398,6 +396,7 @@ static int cancel_cmd(JCR *jcr) cjcr->store_bsock->set_terminated(); pthread_kill(cjcr->my_thread_id, TIMEOUT_SIGNAL); } + generate_plugin_event(cjcr, bEventCancelCommand, NULL); set_jcr_job_status(cjcr, JS_Canceled); free_jcr(cjcr); dir->fsend(_("2001 Job %s marked to be canceled.\n"), Job); @@ -471,6 +470,7 @@ static int job_cmd(JCR *jcr) free_pool_memory(sd_auth_key); Dmsg2(120, "JobId=%d Auth=%s\n", jcr->JobId, jcr->sd_auth_key); Mmsg(jcr->errmsg, "JobId=%d Job=%s", jcr->JobId, jcr->Job); + new_plugins(jcr); /* instantiate plugins for this jcr */ generate_plugin_event(jcr, bEventJobStart, (void *)jcr->errmsg); return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER); } diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index ca961db1ca..4c9c0a3054 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -670,7 +670,9 @@ JCR *get_jcr_by_full_name(char *Job) void set_jcr_job_status(JCR *jcr, int JobStatus) { - bool set_waittime=false; + bool set_waittime = false; + int oldJobStatus = jcr->JobStatus; + Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus); /* if wait state is new, we keep current time for watchdog MaxWaitTime */ switch (JobStatus) { @@ -732,8 +734,11 @@ void set_jcr_job_status(JCR *jcr, int JobStatus) jcr->wait_time = time(NULL); } } - Dmsg3(200, "jid=%u leave set_jcr_job_status=%c set=%c\n", (uint32_t)jcr->JobId, - jcr->JobStatus, JobStatus); + if (oldJobStatus != jcr->JobStatus) { + Dmsg3(200, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId, + oldJobStatus, JobStatus); +// generate_plugin_event(jcr, bEventStatusChange, NULL); + } } #ifdef TRACE_JCR_CHAIN diff --git a/bacula/src/version.h b/bacula/src/version.h index 152c07dfe0..9bc38c7037 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.5.7" -#define BDATE "28 September 2008" -#define LSMDATE "28Sep08" +#define VERSION "2.5.8" +#define BDATE "29 September 2008" +#define LSMDATE "29Sep08" #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.5 b/bacula/technotes-2.5 index d7d52e4d7a..65c67b424f 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -17,6 +17,10 @@ dbdriver remove reader/writer in FOPTS???? General: +29Sep08 +kes Create plugin instance only when FD job starts. +kes Add new FD plugin event: bEventCancelCommand when + a cancel command is issued to the FD. 28Sep08 kes Add cmd_plugin flag to jcr so we can globally know if a command plugin is running. -- 2.39.5