From: Eric Bollengier Date: Fri, 28 May 2010 11:37:58 +0000 (+0200) Subject: Convert all Jmsg on the watchdog thread to Qmsg X-Git-Tag: Release-5.2.1~1324 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b0127bcd49eeaf24111a95d813e31599a11f623d;p=bacula%2Fbacula Convert all Jmsg on the watchdog thread to Qmsg --- diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 638c4c259a..def39b8d85 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1218,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+len, sizeof(rbuf)-len, 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; } diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index 701d98e2c0..450a70ad8b 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -341,6 +341,7 @@ int stop_watchdog(void); watchdog_t *new_watchdog(void); bool register_watchdog(watchdog_t *wd); bool unregister_watchdog(watchdog_t *wd); +bool is_watchdog(); /* timers.c */ btimer_t *start_child_timer(JCR *jcr, pid_t pid, uint32_t wait); diff --git a/bacula/src/lib/watchdog.c b/bacula/src/lib/watchdog.c index 770597dbba..3c70ffc783 100644 --- a/bacula/src/lib/watchdog.c +++ b/bacula/src/lib/watchdog.c @@ -60,6 +60,19 @@ static pthread_t wd_tid; static dlist *wd_queue; static dlist *wd_inactive; +/* + * Returns: 0 if the current thread is NOT the watchdog + * 1 if the current thread is the watchdog + */ +bool is_watchdog() +{ + if (wd_is_init && pthread_equal(pthread_self(), wd_tid)) { + return true; + } else { + return false; + } +} + /* * Start watchdog thread *