From: Kern Sibbald Date: Sun, 28 May 2017 13:01:06 +0000 (+0200) Subject: Attempt to fix deadlock in FreeBSD maxtime-test X-Git-Tag: Release-7.9.1~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=700d80306874f392d01b5ab08039156bd9009ffb;p=bacula%2Fbacula Attempt to fix deadlock in FreeBSD maxtime-test --- diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 0dd596f30c..ad76d857bb 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -42,6 +42,7 @@ sql_escape_call p_sql_escape = NULL; */ dlist *daemon_msg_queue = NULL; pthread_mutex_t daemon_msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER; +static bool dequeuing_daemon_msgs = false; const char *working_directory = NULL; /* working directory path stored here */ const char *assert_msg = NULL; /* ASSERT2 error message */ const char *version = VERSION " (" BDATE ")"; @@ -1720,8 +1721,9 @@ void dequeue_messages(JCR *jcr) } /* Dequeue daemon messages */ - if (daemon_msg_queue) { + if (daemon_msg_queue && !dequeuing_daemon_msgs) { P(daemon_msg_queue_mutex); + dequeuing_daemon_msgs = true; jcr->dequeuing_msgs = true; JobId = jcr->JobId; jcr->JobId = 0; /* set daemon JobId == 0 */ @@ -1732,11 +1734,12 @@ void dequeue_messages(JCR *jcr) daemon_msg_queue->destroy(); jcr->JobId = JobId; /* restore JobId */ jcr->dequeuing_msgs = false; + dequeuing_daemon_msgs = false; V(daemon_msg_queue_mutex); } /* Dequeue Job specific messages */ - if (!jcr->msg_queue) { + if (!jcr->msg_queue || jcr->dequeuing_msgs) { return; } P(jcr->msg_queue_mutex);