ApiListener::Ptr listener = ApiListener::GetInstance();
listener->RemoveHttpClient(this);
- m_Stream->Shutdown();
+ if (!m_Stream->IsEof())
+ m_Stream->Shutdown();
}
bool HttpServerConnection::ProcessMessage(void)
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);
- Disconnect();
+ try {
+ while (ProcessMessage())
+ ; /* empty loop body */
+ } catch (const std::exception& ex) {
+ Log(LogWarning, "HttpServerConnection")
+ << "Error while reading Http request: " << DiagnosticInformation(ex);
- return;
- }
+ close = true;
+ }
+ } else
+ close = true;
- if (m_Stream->IsEof())
+ if (close)
Disconnect();
}
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);
- Disconnect();
+ 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);
- return;
- }
+ Disconnect();
- if (m_Stream->IsEof())
+ return;
+ }
+ } else
+ close = true;
+
+ if (close)
Disconnect();
}