]> granicus.if.org Git - icinga2/commitdiff
HttpServerConnection#StartStreaming(): auto-detect disconnection
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Wed, 3 Apr 2019 07:50:52 +0000 (09:50 +0200)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Wed, 3 Apr 2019 07:50:52 +0000 (09:50 +0200)
lib/remote/httpserverconnection.cpp

index 5c40e2e83f678488129a59c8d7d74e711a833ca3..7d08d8ae43b5146299191b242494c8c214a7b7a7 100644 (file)
@@ -93,7 +93,25 @@ void HttpServerConnection::Disconnect()
 
 void HttpServerConnection::StartStreaming()
 {
+       namespace asio = boost::asio;
+
        m_HasStartedStreaming = true;
+
+       HttpServerConnection::Ptr keepAlive (this);
+
+       asio::spawn(m_IoStrand, [this, keepAlive](asio::yield_context yc) {
+               if (!m_ShuttingDown) {
+                       char buf[128];
+                       asio::mutable_buffer readBuf (buf, 128);
+                       boost::system::error_code ec;
+
+                       do {
+                               m_Stream->async_read_some(readBuf, yc[ec]);
+                       } while (!ec);
+
+                       Disconnect();
+               }
+       });
 }
 
 static inline