From 2e5af2922b7deb11d61e55879a7f7de5f0d6d298 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 3 Apr 2019 09:59:45 +0200 Subject: [PATCH] /v1/events: terminate on disconnect --- lib/remote/eventshandler.cpp | 2 ++ lib/remote/httpserverconnection.cpp | 5 +++++ lib/remote/httpserverconnection.hpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/lib/remote/eventshandler.cpp b/lib/remote/eventshandler.cpp index 5e8e05901..4bc028514 100644 --- a/lib/remote/eventshandler.cpp +++ b/lib/remote/eventshandler.cpp @@ -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; } } } diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index 7d08d8ae4..c06e381e2 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -114,6 +114,11 @@ void HttpServerConnection::StartStreaming() }); } +bool HttpServerConnection::Disconnected() +{ + return m_ShuttingDown; +} + static inline bool EnsureValidHeaders( AsioTlsStream& stream, diff --git a/lib/remote/httpserverconnection.hpp b/lib/remote/httpserverconnection.hpp index 56876829c..b32db86a6 100644 --- a/lib/remote/httpserverconnection.hpp +++ b/lib/remote/httpserverconnection.hpp @@ -29,6 +29,8 @@ public: void Disconnect(); void StartStreaming(); + bool Disconnected(); + private: ApiUser::Ptr m_ApiUser; std::shared_ptr m_Stream;