Fix crash in HttpServerConnection::ProcessMessageAsync

fixes #12493
This commit is contained in:
Gunnar Beutner 2016-08-19 20:35:20 +02:00
parent c08ad9fd12
commit b42bfc822b
2 changed files with 19 additions and 2 deletions

View File

@ -80,7 +80,14 @@ void HttpServerConnection::Disconnect(void)
ApiListener::Ptr listener = ApiListener::GetInstance(); ApiListener::Ptr listener = ApiListener::GetInstance();
listener->RemoveHttpClient(this); listener->RemoveHttpClient(this);
m_Stream->Shutdown(); m_CurrentRequest.~HttpRequest();
new (&m_CurrentRequest) HttpRequest(Stream::Ptr());
{
Stream::Ptr stream = m_Stream;
m_Stream.reset();
stream->Close();
}
} }
bool HttpServerConnection::ProcessMessage(void) bool HttpServerConnection::ProcessMessage(void)
@ -204,6 +211,9 @@ void HttpServerConnection::DataAvailableHandler(void)
{ {
bool close = false; bool close = false;
if (!m_Stream)
return;
if (!m_Stream->IsEof()) { if (!m_Stream->IsEof()) {
boost::mutex::scoped_lock lock(m_DataHandlerMutex); boost::mutex::scoped_lock lock(m_DataHandlerMutex);

View File

@ -129,7 +129,11 @@ void JsonRpcConnection::Disconnect(void)
Log(LogWarning, "JsonRpcConnection") Log(LogWarning, "JsonRpcConnection")
<< "API client disconnected for identity '" << m_Identity << "'"; << "API client disconnected for identity '" << m_Identity << "'";
m_Stream->Close(); {
Stream::Ptr stream = m_Stream;
m_Stream.reset();
stream->Close();
}
if (m_Endpoint) if (m_Endpoint)
m_Endpoint->RemoveClient(this); m_Endpoint->RemoveClient(this);
@ -234,6 +238,9 @@ void JsonRpcConnection::DataAvailableHandler(void)
{ {
bool close = false; bool close = false;
if (!m_Stream)
return;
if (!m_Stream->IsEof()) { if (!m_Stream->IsEof()) {
boost::mutex::scoped_lock lock(m_DataHandlerMutex); boost::mutex::scoped_lock lock(m_DataHandlerMutex);