[icinga-checkins] icinga.org: icinga2/master: Make sure all threads are dead before calling fork()

git at icinga.org git at icinga.org
Wed Nov 12 21:28:02 CET 2014


Module: icinga2
Branch: master
Commit: f592a13481ec42fb555474d1f1e231f8ed9b5b67
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=f592a13481ec42fb555474d1f1e231f8ed9b5b67

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Nov 12 21:27:36 2014 +0100

Make sure all threads are dead before calling fork()

fixes #7653

---

 lib/base/application.cpp |    9 +--------
 lib/base/application.hpp |    1 -
 lib/base/timer.cpp       |    3 ++-
 test/test.cpp            |    4 +++-
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/lib/base/application.cpp b/lib/base/application.cpp
index 786cda1..204ca75 100644
--- a/lib/base/application.cpp
+++ b/lib/base/application.cpp
@@ -109,7 +109,7 @@ void Application::Exit(int rc)
 		logger->Flush();
 	}
 
-	UninitializeBase();
+	Timer::Uninitialize();
 
 #ifdef _DEBUG
 	exit(rc);
@@ -120,8 +120,6 @@ void Application::Exit(int rc)
 
 void Application::InitializeBase(void)
 {
-	Timer::Initialize();
-
 #ifndef _WIN32
 	rlimit rl;
 	if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
@@ -154,11 +152,6 @@ void Application::InitializeBase(void)
 	Utility::ExecuteDeferredInitializers();
 }
 
-void Application::UninitializeBase(void)
-{
-	Timer::Uninitialize();
-}
-
 /**
  * Retrieves a pointer to the application singleton object.
  *
diff --git a/lib/base/application.hpp b/lib/base/application.hpp
index 862237a..42db856 100644
--- a/lib/base/application.hpp
+++ b/lib/base/application.hpp
@@ -43,7 +43,6 @@ public:
 	~Application(void);
 
 	static void InitializeBase(void);
-	static void UninitializeBase(void);
 
 	static Application::Ptr GetInstance(void);
 
diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp
index d07774c..c16e41b 100644
--- a/lib/base/timer.cpp
+++ b/lib/base/timer.cpp
@@ -81,7 +81,8 @@ void Timer::Uninitialize(void)
 		l_CV.notify_all();
 	}
 
-	l_Thread.join();
+	if (l_Thread.joinable())
+		l_Thread.join();
 }
 
 /**
diff --git a/test/test.cpp b/test/test.cpp
index 4076eae..d4fc3d2 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -21,6 +21,7 @@
 #define BOOST_TEST_MODULE icinga2_test
 
 #include "base/application.hpp"
+#include "base/timer.hpp"
 #include <BoostTestTargetConfig.h>
 
 using namespace icinga;
@@ -30,11 +31,12 @@ struct InitLibBase
 	InitLibBase(void)
 	{
 		Application::InitializeBase();
+		Timer::Initialize();
 	}
 
 	~InitLibBase(void)
 	{
-		Application::UninitializeBase();
+		Timer::Uninitialize();
 	}
 };
 



More information about the icinga-checkins mailing list