From 71700cff6cd0b700e41888df91cf4b13eb1424f5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 26 Jun 2017 13:31:59 +0200 Subject: [PATCH] Ensure we have a DIR connection in dequeue_messages --- bacula/src/lib/message.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index ad76d857bb..e39f678ed4 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1715,8 +1715,9 @@ void dequeue_messages(JCR *jcr) MQUEUE_ITEM *item; JobId_t JobId; - /* Avoid bad calls and recursion */ - if (jcr == NULL || jcr->dequeuing_msgs) { + /* Avoid bad calls, recursion and no Director connection */ + if (jcr == NULL || jcr->dequeuing_msgs || + jcr->dir_bsock == NULL || jcr->dir_bsock->is_closed()) { return; } @@ -1727,9 +1728,11 @@ void dequeue_messages(JCR *jcr) jcr->dequeuing_msgs = true; JobId = jcr->JobId; jcr->JobId = 0; /* set daemon JobId == 0 */ + jcr->dir_bsock->suppress_error_messages(true); foreach_dlist(item, daemon_msg_queue) { Jmsg(jcr, item->type, item->mtime, "%s", item->msg); } + jcr->dir_bsock->suppress_error_messages(false); /* Remove messages just sent */ daemon_msg_queue->destroy(); jcr->JobId = JobId; /* restore JobId */ @@ -1744,9 +1747,11 @@ void dequeue_messages(JCR *jcr) } P(jcr->msg_queue_mutex); jcr->dequeuing_msgs = true; + jcr->dir_bsock->suppress_error_messages(true); foreach_dlist(item, jcr->msg_queue) { Jmsg(jcr, item->type, item->mtime, "%s", item->msg); } + jcr->dir_bsock->suppress_error_messages(false); /* Remove messages just sent */ jcr->msg_queue->destroy(); jcr->dequeuing_msgs = false; -- 2.39.5