]> granicus.if.org Git - icinga2/commitdiff
ApiListener#ListenerCoroutineProc(): catch more edge cases
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 18 Feb 2019 13:23:59 +0000 (14:23 +0100)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 1 Apr 2019 09:40:14 +0000 (11:40 +0200)
lib/remote/apilistener.cpp

index 6e9cc8b7b4ee47b9b8ae17969694e02a057ddd4e..c0b75aecf7b51f1d566ed3aac3ebd9cca7e240ae 100644 (file)
@@ -409,19 +409,17 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const std
        namespace asio = boost::asio;
 
        auto& io (server->get_io_service());
-       auto sslConn (std::make_shared<AsioTlsStream>(io, *sslContext));
 
        for (;;) {
                try {
+                       auto sslConn (std::make_shared<AsioTlsStream>(io, *sslContext));
+
                        server->async_accept(sslConn->lowest_layer(), yc);
+
+                       asio::spawn(io, [this, sslConn](asio::yield_context yc) { NewClientHandler(yc, sslConn, String(), RoleServer); });
                } catch (const std::exception& ex) {
                        Log(LogCritical, "ApiListener") << "Cannot accept new connection: " << DiagnosticInformation(ex, false);
-                       continue;
                }
-
-               asio::spawn(io, [this, sslConn](asio::yield_context yc) { NewClientHandler(yc, sslConn, String(), RoleServer); });
-
-               sslConn = std::make_shared<AsioTlsStream>(io, *sslContext);
        }
 }