Browse Source

Another fix to Network life cycle.

Adam Ierymenko 11 years ago
parent
commit
eadff71d37
2 changed files with 9 additions and 2 deletions
  1. 8 2
      node/Network.cpp
  2. 1 0
      osnet/OSXEthernetTap.cpp

+ 8 - 2
node/Network.cpp

@@ -64,7 +64,11 @@ const char *Network::statusString(const Status s)
 
 Network::~Network()
 {
-	Thread::join(_setupThread);
+	_lock.lock();
+	if ((_setupThread)&&(!_destroyed)) {
+		_lock.unlock();
+		Thread::join(_setupThread);
+	} else _lock.unlock();
 
 	{
 		Mutex::Lock _l(_lock);
@@ -414,7 +418,9 @@ void Network::destroy()
 	_enabled = false;
 	_destroyed = true;
 
-	Thread::join(_setupThread);
+	if (_setupThread)
+		Thread::join(_setupThread);
+	_setupThread = Thread();
 
 	if (_tap)
 		_r->tapFactory->close(_tap,true);

+ 1 - 0
osnet/OSXEthernetTap.cpp

@@ -262,6 +262,7 @@ static inline void _intl_freeifmaddrs(struct _intl_ifmaddrs *ifmp)
 
 #include "../node/Constants.hpp"
 #include "../node/Utils.hpp"
+#include "../node/Mutex.hpp"
 #include "OSXEthernetTap.hpp"
 
 // ff:ff:ff:ff:ff:ff with no ADI