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.0.3~107 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c88dccb88f3cc32a5e2a33301c7fea18cb2c2141;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 e403ec9ea7..ff4c076030 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1216,11 +1216,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 7e700bdad7..7a393398ca 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -339,6 +339,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 *