]> granicus.if.org Git - icinga2/commitdiff
/v1/events: terminate on disconnect
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Wed, 3 Apr 2019 07:59:45 +0000 (09:59 +0200)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Wed, 3 Apr 2019 07:59:45 +0000 (09:59 +0200)
lib/remote/eventshandler.cpp
lib/remote/httpserverconnection.cpp
lib/remote/httpserverconnection.hpp

index 5e8e0590173b310ea70e83995195340b2dc3c70b..4bc0285149ee0f39ac47c653c2b02b38e5d1c04b 100644 (file)
@@ -117,6 +117,8 @@ bool EventsHandler::HandleRequest(
                        asio::async_write(stream, payload, yc);
                        asio::async_write(stream, newLine, yc);
                        stream.async_flush(yc);
+               } else if (server.Disconnected()) {
+                       return true;
                }
        }
 }
index 7d08d8ae43b5146299191b242494c8c214a7b7a7..c06e381e2392bb3d8d64e88e53abd4b384dc9f83 100644 (file)
@@ -114,6 +114,11 @@ void HttpServerConnection::StartStreaming()
        });
 }
 
+bool HttpServerConnection::Disconnected()
+{
+       return m_ShuttingDown;
+}
+
 static inline
 bool EnsureValidHeaders(
        AsioTlsStream& stream,
index 56876829ca6b01b712410375ca998a8edd313c66..b32db86a6c91da3e0216280a4572ee2add54852d 100644 (file)
@@ -29,6 +29,8 @@ public:
        void Disconnect();
        void StartStreaming();
 
+       bool Disconnected();
+
 private:
        ApiUser::Ptr m_ApiUser;
        std::shared_ptr<AsioTlsStream> m_Stream;