From 5bf1ae51408a3fd0183548b586c7bd3173935cf3 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 23 Oct 2009 17:05:00 +0200 Subject: [PATCH] Disallow Qmsg when despooling --- bacula/src/jcr.h | 1 + bacula/src/lib/message.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 16a4d7d2d8..58ae568437 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -214,6 +214,7 @@ public: JCR_free_HANDLER *daemon_free_jcr; /* Local free routine */ dlist *msg_queue; /* Queued messages */ pthread_mutex_t msg_queue_mutex; /* message queue mutex */ + bool dequeuing_msgs; /* Set when dequeuing messages */ alist job_end_push; /* Job end pushed calls */ POOLMEM *VolumeName; /* Volume name desired -- pool_memory */ POOLMEM *errmsg; /* edited error message */ diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index d9abff3bcc..6cb762d874 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1361,6 +1361,13 @@ void Qmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...) /* jcr==NULL => daemon message, safe to send now */ Jmsg(jcr, item->type, item->mtime, "%s", item->msg); free(item); + /* + * If we are dequeuing, we cannot queue another item, + * so as a last resort send it to the syslog + */ + } else if (jcr->dequeuing_msgs) { + syslog(LOG_DAEMON|LOG_ERR, "%s", item->msg); + free(item); } else { /* Queue message for later sending */ P(jcr->msg_queue_mutex); @@ -1380,11 +1387,13 @@ void dequeue_messages(JCR *jcr) return; } P(jcr->msg_queue_mutex); + jcr->dequeuing_msgs = true; foreach_dlist(item, jcr->msg_queue) { Jmsg(jcr, item->type, item->mtime, "%s", item->msg); } /* Remove messages just sent */ jcr->msg_queue->destroy(); + jcr->dequeuing_msgs = false; V(jcr->msg_queue_mutex); } -- 2.39.5