Fix some deadlocks in the TlsStream class.

This commit is contained in:
Gunnar Beutner 2013-03-12 11:56:14 +01:00
parent 4b2d828b99
commit 91c82263a5
2 changed files with 4 additions and 6 deletions

View File

@ -42,8 +42,6 @@ TlsStream::TlsStream(const Stream::Ptr& innerStream, TlsRole role, shared_ptr<SS
void TlsStream::Start(void)
{
ObjectLock olock(this);
m_SSL = shared_ptr<SSL>(SSL_new(m_SSLContext.get()), SSL_free);
m_SSLContext.reset();
@ -54,7 +52,7 @@ void TlsStream::Start(void)
<< errinfo_openssl_error(ERR_get_error()));
}
if (!GetClientCertificate())
if (!m_SSL)
BOOST_THROW_EXCEPTION(logic_error("No X509 client certificate was specified."));
if (!m_SSLIndexInitialized) {

View File

@ -111,7 +111,7 @@ void EndpointManager::AddListener(const String& service)
{
ObjectLock olock(this);
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext)
BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddListener()"));
@ -140,7 +140,7 @@ void EndpointManager::AddListener(const String& service)
void EndpointManager::AddConnection(const String& node, const String& service) {
ObjectLock olock(this);
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext)
BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddConnection()"));
@ -160,7 +160,7 @@ void EndpointManager::NewClientHandler(const Socket::Ptr& client, TlsRole role)
ObjectLock olock(this);
String peerAddress = client->GetPeerAddress();
TlsStream::Ptr tlsStream = boost::make_shared<TlsStream>(client, role, GetSSLContext());
TlsStream::Ptr tlsStream = boost::make_shared<TlsStream>(client, role, m_SSLContext);
tlsStream->Start();
m_PendingClients.insert(tlsStream);