]> git.sur5r.net Git - bacula/bacula/commitdiff
Ensure we have a DIR connection in dequeue_messages
authorKern Sibbald <kern@sibbald.com>
Mon, 26 Jun 2017 11:31:59 +0000 (13:31 +0200)
committerKern Sibbald <kern@sibbald.com>
Mon, 26 Jun 2017 11:31:59 +0000 (13:31 +0200)
bacula/src/lib/message.c

index ad76d857bb10df27aa6327f925c6478630bec17e..e39f678ed434ce23c8aad3630d8d49dabfd18907 100644 (file)
@@ -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;