diff --git a/lib/base/socketevents.cpp b/lib/base/socketevents.cpp index 045563ba2..a9594db37 100644 --- a/lib/base/socketevents.cpp +++ b/lib/base/socketevents.cpp @@ -166,10 +166,12 @@ void SocketEvents::WakeUpThread(bool wait) l_SocketIOFDChanged = true; - (void) send(l_SocketIOEventFDs[1], "T", 1, 0); + while (l_SocketIOFDChanged) { + (void) send(l_SocketIOEventFDs[1], "T", 1, 0); - while (l_SocketIOFDChanged) - l_SocketIOCV.wait(lock); + boost::system_time const timeout = boost::get_system_time() + boost::posix_time::milliseconds(50); + l_SocketIOCV.timed_wait(lock, timeout); + } } } else { (void) send(l_SocketIOEventFDs[1], "T", 1, 0); diff --git a/lib/base/stream.cpp b/lib/base/stream.cpp index 5b465cba3..1f3bce70f 100644 --- a/lib/base/stream.cpp +++ b/lib/base/stream.cpp @@ -22,7 +22,7 @@ using namespace icinga; -void Stream::RegisterDataHandler(const boost::function& handler) +void Stream::RegisterDataHandler(const boost::function& handler) { if (SupportsWaiting()) OnDataAvailable.connect(handler); @@ -42,7 +42,7 @@ bool Stream::IsDataAvailable(void) const void Stream::SignalDataAvailable(void) { - OnDataAvailable(); + OnDataAvailable(this); { boost::mutex::scoped_lock lock(m_Mutex); diff --git a/lib/base/stream.hpp b/lib/base/stream.hpp index 9754d3b36..05b194ffd 100644 --- a/lib/base/stream.hpp +++ b/lib/base/stream.hpp @@ -114,7 +114,7 @@ public: virtual bool IsDataAvailable(void) const; - void RegisterDataHandler(const boost::function& handler); + void RegisterDataHandler(const boost::function& handler); StreamReadStatus ReadLine(String *line, StreamReadContext& context, bool may_wait = false); @@ -122,7 +122,7 @@ protected: void SignalDataAvailable(void); private: - boost::signals2::signal OnDataAvailable; + boost::signals2::signal OnDataAvailable; boost::mutex m_Mutex; boost::condition_variable m_CV; diff --git a/lib/base/tlsstream.cpp b/lib/base/tlsstream.cpp index 6f6ab788b..235c9eb44 100644 --- a/lib/base/tlsstream.cpp +++ b/lib/base/tlsstream.cpp @@ -184,10 +184,12 @@ void TlsStream::OnEvent(int revents) if (rc > 0) { m_CurrentAction = TlsActionNone; - if (m_SendQ->GetAvailableBytes() > 0) - ChangeEvents(POLLIN|POLLOUT); - else - ChangeEvents(POLLIN); + if (!m_Eof) { + if (m_SendQ->GetAvailableBytes() > 0) + ChangeEvents(POLLIN|POLLOUT); + else + ChangeEvents(POLLIN); + } lock.unlock();