]> granicus.if.org Git - icinga2/commitdiff
HttpServerConnection: don't disconnect during sending response
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 22 Feb 2019 14:38:02 +0000 (15:38 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 1 Apr 2019 11:31:16 +0000 (13:31 +0200)
lib/remote/httpserverconnection.cpp

index 198a472b96b78fc6bc400f57aed6fb844d0e2088..af2a69b42926ec9cbfd5191cc96f252c70151a8e 100644 (file)
@@ -353,7 +353,6 @@ bool ProcessRequest(
        boost::beast::http::request<boost::beast::http::string_body>& request,
        ApiUser::Ptr& authenticatedUser,
        boost::beast::http::response<boost::beast::http::string_body>& response,
-       double& seen,
        boost::asio::yield_context& yc
 )
 {
@@ -364,8 +363,6 @@ bool ProcessRequest(
        try {
                CpuBoundWork handlingRequest (yc);
 
-               Defer updateSeen ([&seen]() { seen = Utility::GetTime(); });
-
                HttpHandler::ProcessRequest(stream, authenticatedUser, request, response, yc, hasStartedStreaming);
        } catch (const std::exception& ex) {
                if (hasStartedStreaming) {
@@ -403,6 +400,8 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
                beast::flat_buffer buf;
 
                for (;;) {
+                       m_Seen = Utility::GetTime();
+
                        http::parser<true, http::string_body> parser;
                        http::response<http::string_body> response;
 
@@ -459,7 +458,7 @@ void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc)
 
                        m_Seen = std::numeric_limits<decltype(m_Seen)>::max();
 
-                       if (!ProcessRequest(*m_Stream, request, authenticatedUser, response, m_Seen, yc)) {
+                       if (!ProcessRequest(*m_Stream, request, authenticatedUser, response, yc)) {
                                break;
                        }