Fix crash in JsonRpcClient::DataAvailableHandler

fixes #10495
This commit is contained in:
Gunnar Beutner 2015-11-02 17:34:01 +01:00
parent 7589c61b38
commit 9c5758958c
3 changed files with 7 additions and 4 deletions

View File

@ -62,7 +62,8 @@ void HttpClientConnection::Reconnect(void)
/* m_Stream = new NetworkStream(socket);
-- does not currently work because the NetworkStream class doesn't support async I/O */
m_Stream->RegisterDataHandler(boost::bind(&HttpClientConnection::DataAvailableHandler, this, _1));
/* the stream holds an owning reference to this object through the callback we're registering here */
m_Stream->RegisterDataHandler(boost::bind(&HttpClientConnection::DataAvailableHandler, HttpClientConnection::Ptr(this), _1));
if (m_Stream->IsDataAvailable())
DataAvailableHandler(m_Stream);
}

View File

@ -55,7 +55,8 @@ void HttpServerConnection::StaticInitialize(void)
void HttpServerConnection::Start(void)
{
m_Stream->RegisterDataHandler(boost::bind(&HttpServerConnection::DataAvailableHandler, this));
/* the stream holds an owning reference to this object through the callback we're registering here */
m_Stream->RegisterDataHandler(boost::bind(&HttpServerConnection::DataAvailableHandler, HttpServerConnection::Ptr(this)));
if (m_Stream->IsDataAvailable())
DataAvailableHandler();
}

View File

@ -60,7 +60,8 @@ void JsonRpcConnection::StaticInitialize(void)
void JsonRpcConnection::Start(void)
{
m_Stream->RegisterDataHandler(boost::bind(&JsonRpcConnection::DataAvailableHandler, this));
/* the stream holds an owning reference to this object through the callback we're registering here */
m_Stream->RegisterDataHandler(boost::bind(&JsonRpcConnection::DataAvailableHandler, JsonRpcConnection::Ptr(this)));
if (m_Stream->IsDataAvailable())
DataAvailableHandler();
}
@ -103,7 +104,7 @@ void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message)
Log(LogWarning, "JsonRpcConnection")
<< info.str() << "\n" << DiagnosticInformation(ex);
Utility::QueueAsyncCallback(boost::bind(&JsonRpcConnection::Disconnect, JsonRpcConnection::Ptr(this)));
Disconnect();
}
}