]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/message.c
Make sure JobErrors is always nonzero on fatal error
[bacula/bacula] / bacula / src / lib / message.c
index e403ec9ea70c577e5a6784fd53eac834cb0de41c..b13b380106c31a294fc13e3b13fd5b3d91755654 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -56,6 +56,8 @@ bool dbg_timestamp = false;           /* print timestamp in debug output */
 bool prt_kaboom = false;              /* Print kaboom output */
 utime_t daemon_start_time = 0;        /* Daemon start time */
 const char *version = VERSION " (" BDATE ")";
+const char *dist_name = DISTNAME " " DISTVER;
+const int beef = BEEF;
 char my_name[30];                     /* daemon name is stored here */
 char host_name[50];                   /* host machine name */
 char *exepath = (char *)NULL;
@@ -1216,11 +1218,24 @@ Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...)
        return;
     }
 
+    /* The watchdog thread can't use Jmsg directly, we always queued it */
+    if (is_watchdog()) {
+       va_start(arg_ptr, fmt);
+       bvsnprintf(rbuf,  sizeof(rbuf), fmt, arg_ptr);
+       va_end(arg_ptr);
+       Qmsg(jcr, type, mtime, "%s", rbuf);
+       return;
+    }
+
     msgs = NULL;
     if (!jcr) {
        jcr = get_jcr_from_tsd();
     }
     if (jcr) {
+       if (!jcr->dequeuing_msgs) { /* Avoid recursion */
+          /* Dequeue messages to keep the original order  */
+          dequeue_messages(jcr); 
+       }
        msgs = jcr->jcr_msgs;
        JobId = jcr->JobId;
     }
@@ -1248,6 +1263,9 @@ Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...)
        if (jcr) {
           set_jcr_job_status(jcr, JS_FatalError);
        }
+       if (jcr && jcr->JobErrors == 0) {
+          jcr->JobErrors = 1;
+       }
        break;
     case M_ERROR:
        len = bsnprintf(rbuf, sizeof(rbuf), _("%s JobId %u: Error: "), my_name, JobId);