mirror of https://github.com/Icinga/icinga2.git
Fix deadlock in {HttpServerConnection,JsonRpcConnection}::DataAvailableHandler
refs #11014
This commit is contained in:
parent
a49f8f142e
commit
55720f3005
|
@ -78,7 +78,8 @@ void HttpServerConnection::Disconnect(void)
|
|||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
listener->RemoveHttpClient(this);
|
||||
|
||||
m_Stream->Shutdown();
|
||||
if (!m_Stream->IsEof())
|
||||
m_Stream->Shutdown();
|
||||
}
|
||||
|
||||
bool HttpServerConnection::ProcessMessage(void)
|
||||
|
@ -196,17 +197,25 @@ void HttpServerConnection::ProcessMessageAsync(HttpRequest& request)
|
|||
|
||||
void HttpServerConnection::DataAvailableHandler(void)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_DataHandlerMutex);
|
||||
bool close = false;
|
||||
|
||||
try {
|
||||
while (ProcessMessage())
|
||||
; /* empty loop body */
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "HttpServerConnection")
|
||||
<< "Error while reading Http request: " << DiagnosticInformation(ex);
|
||||
if (!m_Stream->IsEof()) {
|
||||
boost::mutex::scoped_lock lock(m_DataHandlerMutex);
|
||||
|
||||
try {
|
||||
while (ProcessMessage())
|
||||
; /* empty loop body */
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "HttpServerConnection")
|
||||
<< "Error while reading Http request: " << DiagnosticInformation(ex);
|
||||
|
||||
close = true;
|
||||
}
|
||||
} else
|
||||
close = true;
|
||||
|
||||
if (close)
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
void HttpServerConnection::CheckLiveness(void)
|
||||
|
|
|
@ -227,18 +227,28 @@ bool JsonRpcConnection::ProcessMessage(void)
|
|||
|
||||
void JsonRpcConnection::DataAvailableHandler(void)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_DataHandlerMutex);
|
||||
bool close = false;
|
||||
|
||||
try {
|
||||
while (ProcessMessage())
|
||||
; /* empty loop body */
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "JsonRpcConnection")
|
||||
<< "Error while reading JSON-RPC message for identity '" << m_Identity
|
||||
<< "': " << DiagnosticInformation(ex);
|
||||
if (!m_Stream->IsEof()) {
|
||||
boost::mutex::scoped_lock lock(m_DataHandlerMutex);
|
||||
|
||||
try {
|
||||
while (ProcessMessage())
|
||||
; /* empty loop body */
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "JsonRpcConnection")
|
||||
<< "Error while reading JSON-RPC message for identity '" << m_Identity
|
||||
<< "': " << DiagnosticInformation(ex);
|
||||
|
||||
Disconnect();
|
||||
|
||||
return;
|
||||
}
|
||||
} else
|
||||
close = true;
|
||||
|
||||
if (close)
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
Value SetLogPositionHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
|
||||
|
|
Loading…
Reference in New Issue