From: Kern Sibbald Date: Tue, 18 Sep 2012 10:24:14 +0000 (+0200) Subject: Fix race condition in close_msg that causes seg fault X-Git-Tag: Release-7.0.0~92 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fac8272cb200922e95168bd084511ea0258446e6;p=bacula%2Fbacula Fix race condition in close_msg that causes seg fault --- diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index fc7f22ae7d..2a67c78ea6 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -517,6 +517,11 @@ void close_msg(JCR *jcr) return; } msgs->wait_not_in_use(); /* leaves fides_mutex set */ + /* Note get_closing() does not lock because we are already locked */ + if (msgs->get_closing()) { + msgs->unlock(); + return; + } msgs->set_closing(); msgs->unlock(); diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index f075df7154..0a83353567 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -145,6 +145,7 @@ public: void clear_in_use() { lock(); m_in_use=false; unlock(); } void set_in_use() { wait_not_in_use(); m_in_use=true; unlock(); } void set_closing() { m_closing=true; } + bool get_closing() { return m_closing; } void clear_closing() { lock(); m_closing=false; unlock(); } bool is_closing() { lock(); bool rtn=m_closing; unlock(); return rtn; }