mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Fix another potential deadlock in SocketEvents::WakeUpThread
refs #8484
This commit is contained in:
parent
ba77d7b35f
commit
0fb55060d2
@ -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()) {
|
if (wait) {
|
||||||
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
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);
|
(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;
|
m_FD = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
WakeUpThread();
|
WakeUpThread(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketEvents::ChangeEvents(int events)
|
void SocketEvents::ChangeEvents(int events)
|
||||||
|
@ -51,7 +51,7 @@ private:
|
|||||||
static void InitializeThread(void);
|
static void InitializeThread(void);
|
||||||
static void ThreadProc(void);
|
static void ThreadProc(void);
|
||||||
|
|
||||||
static void WakeUpThread(void);
|
static void WakeUpThread(bool wait = false);
|
||||||
|
|
||||||
int GetPollEvents(void) const;
|
int GetPollEvents(void) const;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user