]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix #6986 About mail wariables not working after conf reload
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Fri, 23 Jul 2021 14:57:53 +0000 (16:57 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:03 +0000 (09:03 +0100)
Callback for changing job codes was changed from being a global one to
per-jcr, so that when reload is executed it is not cleared and stays
until end of the job.

bacula/src/jcr.h
bacula/src/lib/message.c

index f8ef5c314e8763015600ec4e26b7c7b8bcf45eab..b1014c522d0f9d6a52244cd77d046f95c59b5078 100644 (file)
@@ -230,6 +230,7 @@ public:
    void my_thread_send_signal(int sig);   /* in lib/jcr.c */
    void set_killable(bool killable);      /* in lib/jcr.c */
    bool is_killable() const { return my_thread_killable; };
+   job_code_callback_t job_code_callback; /* Callback sending messages defined by the user */
 
    /* Global part of JCR common to all daemons */
    dlink link;                        /* JCR chain link */
index b27876be1adccce18ecf435b235103749ae29dfb..309d2605389a81e449165f58133fb0103644aeaa 100644 (file)
@@ -66,7 +66,6 @@ brwlock_t con_lock;                   /* Console lock structure */
 bool dbg_timestamp = false;           /* print timestamp in debug output */
 bool dbg_thread = false;              /* add thread_id to details */
 bool prt_kaboom = false;              /* Print kaboom output */
-job_code_callback_t message_job_code_callback = NULL;   /* Job code callback. Only used by director. */
 
 /* Forward referenced functions */
 
@@ -363,7 +362,9 @@ init_msg(JCR *jcr, MSGS *msg, job_code_callback_t job_code_callback)
       set_jcr_in_tsd(INVALID_JCR);
    }
 
-   message_job_code_callback = job_code_callback;
+   if (jcr) {
+      jcr->job_code_callback = job_code_callback;
+   }
 
 #if !defined(HAVE_WIN32)
    /*
@@ -574,7 +575,7 @@ static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM *&cmd, DEST *d)
    BPIPE *bpipe;
 
    if (d->mail_cmd) {
-      cmd = edit_job_codes(jcr, cmd, d->mail_cmd, d->where, message_job_code_callback);
+      cmd = edit_job_codes(jcr, cmd, d->mail_cmd, d->where, jcr ? jcr->job_code_callback : NULL);
    } else {
       Mmsg(cmd, "/usr/lib/sendmail -F Bacula %s", d->where);
    }