[icinga-checkins] icinga.org: icinga2/master: Windows: Fixed crash in Object::~Object().

git at icinga.org git at icinga.org
Thu Feb 7 22:13:39 CET 2013


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

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Thu Feb  7 22:13:34 2013 +0100

Windows: Fixed crash in Object::~Object().

---

 lib/base/object.cpp |   28 ++++++++++++++--------------
 lib/base/object.h   |    4 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/base/object.cpp b/lib/base/object.cpp
index 041c541..10b591b 100644
--- a/lib/base/object.cpp
+++ b/lib/base/object.cpp
@@ -27,8 +27,8 @@ using namespace icinga;
 Object::Object(void)
 {
 #ifdef _DEBUG
-	boost::mutex::scoped_lock lock(GetMutex());
-	GetAliveObjects().insert(this);
+	boost::mutex::scoped_lock lock(*GetMutex());
+	GetAliveObjects()->insert(this);
 #endif /* _DEBUG */
 }
 
@@ -38,8 +38,8 @@ Object::Object(void)
 Object::~Object(void)
 {
 #ifdef _DEBUG
-	boost::mutex::scoped_lock lock(GetMutex());
-	GetAliveObjects().erase(this);
+	boost::mutex::scoped_lock lock(*GetMutex());
+	GetAliveObjects()->erase(this);
 #endif /* _DEBUG */
 }
 
@@ -50,7 +50,7 @@ Object::~Object(void)
  */
 void Object::Hold(void)
 {
-	boost::mutex::scoped_lock lock(GetMutex());
+	boost::mutex::scoped_lock lock(*GetMutex());
 	GetHeldObjects().push_back(GetSelf());
 }
 
@@ -59,7 +59,7 @@ void Object::Hold(void)
  */
 void Object::ClearHeldObjects(void)
 {
-	boost::mutex::scoped_lock lock(GetMutex());
+	boost::mutex::scoped_lock lock(*GetMutex());
 	GetHeldObjects().clear();
 }
 
@@ -81,8 +81,8 @@ Object::SharedPtrHolder Object::GetSelf(void)
  */
 int Object::GetAliveObjectsCount(void)
 {
-	boost::mutex::scoped_lock lock(GetMutex());
-	return GetAliveObjects().size();
+	boost::mutex::scoped_lock lock(*GetMutex());
+	return GetAliveObjects()->size();
 }
 
 /**
@@ -95,9 +95,9 @@ void Object::PrintMemoryProfile(void)
 	ofstream dictfp("dictionaries.dump.tmp");
 
 	{
-		boost::mutex::scoped_lock lock(GetMutex());
+		boost::mutex::scoped_lock lock(*GetMutex());
 		set<Object *>::iterator it;
-		BOOST_FOREACH(Object *obj, GetAliveObjects()) {
+		BOOST_FOREACH(Object *obj, *GetAliveObjects()) {
 			pair<map<String, int>::iterator, bool> tt;
 			tt = types.insert(make_pair(Utility::GetTypeName(typeid(*obj)), 1));
 			if (!tt.second)
@@ -130,9 +130,9 @@ void Object::PrintMemoryProfile(void)
  *
  * @returns currently active objects
  */
-set<Object *>& Object::GetAliveObjects(void)
+set<Object *> *Object::GetAliveObjects(void)
 {
-	static set<Object *> aliveObjects;
+	static set<Object *> *aliveObjects = new set<Object *>();
 	return aliveObjects;
 }
 #endif /* _DEBUG */
@@ -142,9 +142,9 @@ set<Object *>& Object::GetAliveObjects(void)
  *
  * @returns a mutex
  */
-boost::mutex& Object::GetMutex(void)
+boost::mutex *Object::GetMutex(void)
 {
-	static boost::mutex mutex;
+	static boost::mutex *mutex = new boost::mutex();
 	return mutex;
 }
 
diff --git a/lib/base/object.h b/lib/base/object.h
index 940f483..fa0fb4c 100644
--- a/lib/base/object.h
+++ b/lib/base/object.h
@@ -109,8 +109,8 @@ private:
 	Object(const Object& other);
 	Object& operator=(const Object& rhs);
 
-	static boost::mutex& GetMutex(void);
-	static set<Object *>& GetAliveObjects(void);
+	static boost::mutex *GetMutex(void);
+	static set<Object *> *GetAliveObjects(void);
 	static vector<Object::Ptr>& GetHeldObjects(void);
 };
 





More information about the icinga-checkins mailing list