Fix another potential deadlock in SocketEvents::WakeUpThread

refs #8484
This commit is contained in:
Gunnar Beutner 2015-02-20 15:23:06 +01:00
parent ba77d7b35f
commit 0fb55060d2
2 changed files with 13 additions and 9 deletions

View File

@ -149,17 +149,21 @@ void SocketEvents::ThreadProc(void)
}
}
void SocketEvents::WakeUpThread(void)
void SocketEvents::WakeUpThread(bool wait)
{
if (boost::this_thread::get_id() != l_SocketIOThread.get_id()) {
boost::mutex::scoped_lock lock(l_SocketIOMutex);
if (wait) {
if (boost::this_thread::get_id() != l_SocketIOThread.get_id()) {
boost::mutex::scoped_lock lock(l_SocketIOMutex);
l_SocketIOFDChanged = true;
l_SocketIOFDChanged = true;
(void) send(l_SocketIOEventFDs[1], "T", 1, 0);
while (l_SocketIOFDChanged)
l_SocketIOCV.wait(lock);
}
} else {
(void) send(l_SocketIOEventFDs[1], "T", 1, 0);
while (l_SocketIOFDChanged)
l_SocketIOCV.wait(lock);
}
}
@ -209,7 +213,7 @@ void SocketEvents::Unregister(void)
m_FD = INVALID_SOCKET;
}
WakeUpThread();
WakeUpThread(true);
}
void SocketEvents::ChangeEvents(int events)

View File

@ -51,7 +51,7 @@ private:
static void InitializeThread(void);
static void ThreadProc(void);
static void WakeUpThread(void);
static void WakeUpThread(bool wait = false);
int GetPollEvents(void) const;