From 817415f6a54fb0fb498d241d9f931c703defb5ce Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Mon, 19 Feb 2018 10:47:14 +0100 Subject: [PATCH] Fix requests not being closed correctly --- lib/remote/httpserverconnection.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index 7c86f9be9..4fba15cb6 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -107,7 +107,11 @@ bool HttpServerConnection::ProcessMessage() response.WriteBody(msg.CStr(), msg.GetLength()); response.Finish(); + m_CurrentRequest.~HttpRequest(); + new (&m_CurrentRequest) HttpRequest(m_Stream); + m_Stream->Shutdown(); + return false; } catch (const std::exception& ex) { response.SetStatus(500, "Internal Server Error"); @@ -115,7 +119,11 @@ bool HttpServerConnection::ProcessMessage() response.WriteBody(msg.CStr(), msg.GetLength()); response.Finish(); + m_CurrentRequest.~HttpRequest(); + new (&m_CurrentRequest) HttpRequest(m_Stream); + m_Stream->Shutdown(); + return false; } return res; @@ -124,7 +132,11 @@ bool HttpServerConnection::ProcessMessage() if (!m_CurrentRequest.CompleteHeaderCheck) { m_CurrentRequest.CompleteHeaderCheck = true; if (!ManageHeaders(response)) { + m_CurrentRequest.~HttpRequest(); + new (&m_CurrentRequest) HttpRequest(m_Stream); + m_Stream->Shutdown(); + return false; } } @@ -138,7 +150,11 @@ bool HttpServerConnection::ProcessMessage() response.WriteBody(msg.CStr(), msg.GetLength()); response.Finish(); + m_CurrentRequest.~HttpRequest(); + new (&m_CurrentRequest) HttpRequest(m_Stream); + m_Stream->Shutdown(); + return false; } catch (const std::exception& ex) { response.SetStatus(500, "Internal Server Error"); @@ -146,7 +162,11 @@ bool HttpServerConnection::ProcessMessage() response.WriteBody(msg.CStr(), msg.GetLength()); response.Finish(); + m_CurrentRequest.~HttpRequest(); + new (&m_CurrentRequest) HttpRequest(m_Stream); + m_Stream->Shutdown(); + return false; } return res;