From 859658ab9864f596b4978bebe3a80eac08b1cba3 Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Thu, 28 Nov 2019 19:56:15 +0100 Subject: [PATCH] Fix TLS context copies in ApiListener This avoids copying the TLS context in the ApiListener class and removes the obsolete variable. This is a follow-up from #7654 --- lib/remote/apilistener.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 31c11d6e7..5566affca 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -356,9 +356,7 @@ bool ApiListener::AddListener(const String& node, const String& service) ObjectLock olock(this); - auto sslContext (m_SSLContext); - - if (!sslContext) { + if (!m_SSLContext) { Log(LogCritical, "ApiListener", "SSL context is required for AddListener()"); return false; } @@ -453,16 +451,14 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint) namespace asio = boost::asio; using asio::ip::tcp; - auto sslContext (m_SSLContext); - - if (!sslContext) { + if (!m_SSLContext) { Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()"); return; } auto& io (IoEngine::Get().GetIoContext()); - IoEngine::SpawnCoroutine(io, [this, endpoint, &io, sslContext](asio::yield_context yc) { + IoEngine::SpawnCoroutine(io, [this, endpoint, &io](asio::yield_context yc) { String host = endpoint->GetHost(); String port = endpoint->GetPort(); @@ -470,7 +466,7 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint) << "Reconnecting to endpoint '" << endpoint->GetName() << "' via host '" << host << "' and port '" << port << "'"; try { - auto sslConn (Shared::Make(io, *sslContext, endpoint->GetName())); + auto sslConn (Shared::Make(io, *m_SSLContext, endpoint->GetName())); Connect(sslConn->lowest_layer(), host, port, yc);