]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix race condition in close_msg that causes seg fault
authorKern Sibbald <kern@sibbald.com>
Tue, 18 Sep 2012 10:24:14 +0000 (12:24 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:51:02 +0000 (14:51 +0200)
bacula/src/lib/message.c
bacula/src/lib/parse_conf.h

index fc7f22ae7dc91c3d8269e275b7a63f5556d74093..2a67c78ea6d35f48ca49b0d5bf4fabde5df9b49c 100644 (file)
@@ -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();
 
index f075df7154bfe83d64f2b69dfa7c54020632c820..0a833535673868dc94bc73aea636d58a8d17da39 100644 (file)
@@ -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; }