From 71e6eae23f733501f3a001788a4f59b1cd54a77f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 12 Apr 2014 13:09:25 +0200 Subject: [PATCH] Fix race condition in AgentListener::NewClientHandler. Refs #4865 --- components/agent/agentlistener.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/agent/agentlistener.cpp b/components/agent/agentlistener.cpp index 3d4675afa..469a9b95c 100644 --- a/components/agent/agentlistener.cpp +++ b/components/agent/agentlistener.cpp @@ -137,7 +137,13 @@ void AgentListener::NewClientHandler(const Socket::Ptr& client, TlsRole role) NetworkStream::Ptr netStream = make_shared(client); - TlsStream::Ptr tlsStream = make_shared(netStream, role, m_SSLContext); + TlsStream::Ptr tlsStream; + + { + ObjectLock olock(this); + tlsStream = make_shared(netStream, role, m_SSLContext); + } + tlsStream->Handshake(); shared_ptr cert = tlsStream->GetPeerCertificate();