Fix for crazy Windows threading bug... repeatedly adding and removing a network now doesn't leave networks in limbo.
This commit is contained in:
parent
44d58ee871
commit
de4e29288d
8 changed files with 166 additions and 169 deletions
|
@ -31,12 +31,13 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include "Constants.hpp"
|
||||
#include "AtomicCounter.hpp"
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#include <string.h>
|
||||
#include "Mutex.hpp"
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
|
@ -56,6 +57,7 @@ public:
|
|||
throw()
|
||||
{
|
||||
_th = NULL;
|
||||
_tid = 0;
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
|
@ -71,8 +73,15 @@ public:
|
|||
|
||||
static inline void join(const Thread &t)
|
||||
{
|
||||
if (t._th != NULL)
|
||||
WaitForSingleObject(t._th,INFINITE);
|
||||
if (t._th != NULL) {
|
||||
for(;;) {
|
||||
DWORD ec = STILL_ACTIVE;
|
||||
GetExitCodeThread(t._th,&ec);
|
||||
if (ec == STILL_ACTIVE)
|
||||
WaitForSingleObject(t._th,1000);
|
||||
else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void sleep(unsigned long ms)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue