]> granicus.if.org Git - icinga2/commitdiff
JsonRpcConnection: Don't swallow exceptions in Boost.Coroutine 7483/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 9 Sep 2019 07:26:12 +0000 (09:26 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 9 Sep 2019 07:26:12 +0000 (09:26 +0200)
refs #7351

lib/remote/httpserverconnection.cpp
lib/remote/jsonrpcconnection.cpp

index e9c834d3ab7e5e5c4dfeb2d129d4a5debb85e84a..01b32f403b36370d5e402313d1138144915c37fc 100644 (file)
@@ -78,6 +78,14 @@ void HttpServerConnection::Disconnect()
                        Log(LogInformation, "HttpServerConnection")
                                << "HTTP client disconnected (from " << m_PeerAddress << ")";
 
+                       /*
+                        * Do not swallow exceptions in a coroutine.
+                        * https://github.com/Icinga/icinga2/issues/7351
+                        * We must not catch `detail::forced_unwind exception` as
+                        * this is used for unwinding the stack.
+                        *
+                        * Just use the error_code dummy here.
+                        */
                        boost::system::error_code ec;
 
                        m_Stream->next_layer().async_shutdown(yc[ec]);
index 3c775f68d7602fba3ae94385a43bb79272f6e21e..e63f1183ab696cad12c38a043589fcfb2bdbab0e 100644 (file)
@@ -214,20 +214,21 @@ void JsonRpcConnection::Disconnect()
 
                        m_WriterDone.Wait(yc);
 
-                       try {
-                               m_Stream->next_layer().async_shutdown(yc);
-                       } catch (...) {
-                       }
+                       /*
+                        * Do not swallow exceptions in a coroutine.
+                        * https://github.com/Icinga/icinga2/issues/7351
+                        * We must not catch `detail::forced_unwind exception` as
+                        * this is used for unwinding the stack.
+                        *
+                        * Just use the error_code dummy here.
+                        */
+                       boost::system::error_code ec;
 
-                       try {
-                               m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both);
-                       } catch (...) {
-                       }
+                       m_Stream->next_layer().async_shutdown(yc[ec]);
 
-                       try {
-                               m_Stream->lowest_layer().cancel();
-                       } catch (...) {
-                       }
+                       m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec);
+
+                       m_Stream->lowest_layer().cancel(ec);
 
                        m_CheckLivenessTimer.cancel();
                        m_HeartbeatTimer.cancel();