]> granicus.if.org Git - icinga2/commitdiff
Fix deadlock in ThreadPool::Join.
authorGunnar Beutner <gunnar@beutner.name>
Thu, 31 Oct 2013 18:09:51 +0000 (19:09 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 31 Oct 2013 18:10:36 +0000 (19:10 +0100)
Refs #4986

lib/base/threadpool.cpp

index 942da06e5592c921590c41e2d96483c8db4a3b3b..71e5aad5473e59fdb72c2603a3deec6d8853ccbe 100644 (file)
@@ -236,7 +236,8 @@ void ThreadPool::ManagerThreadProc(void)
                {
                        boost::mutex::scoped_lock lock(m_Mutex);
 
-                       m_MgmtCV.timed_wait(lock, boost::posix_time::seconds(5));
+                       if (!m_Stopped)
+                               m_MgmtCV.timed_wait(lock, boost::posix_time::seconds(5));
 
                        if (m_Stopped)
                                break;
@@ -345,7 +346,8 @@ void ThreadPool::StatsThreadProc(void)
        for (;;) {
                boost::mutex::scoped_lock lock(m_Mutex);
 
-               m_MgmtCV.timed_wait(lock, boost::posix_time::milliseconds(250));
+               if (!m_Stopped)
+                       m_MgmtCV.timed_wait(lock, boost::posix_time::milliseconds(250));
 
                if (m_Stopped)
                        break;