From 3fe818b44bc493c09940279039d1790aef89da2e 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 706ee33a2..8b0bb5ce6 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -107,7 +107,11 @@ bool HttpServerConnection::ProcessMessage(void) 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(void) 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(void) 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(void) 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(void) response.WriteBody(msg.CStr(), msg.GetLength()); response.Finish(); + m_CurrentRequest.~HttpRequest(); + new (&m_CurrentRequest) HttpRequest(m_Stream); + m_Stream->Shutdown(); + return false; } return res;