mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 23:54:07 +02:00
Fix some deadlocks in the TlsStream class.
This commit is contained in:
parent
4b2d828b99
commit
91c82263a5
@ -42,8 +42,6 @@ TlsStream::TlsStream(const Stream::Ptr& innerStream, TlsRole role, shared_ptr<SS
|
|||||||
|
|
||||||
void TlsStream::Start(void)
|
void TlsStream::Start(void)
|
||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
|
||||||
|
|
||||||
m_SSL = shared_ptr<SSL>(SSL_new(m_SSLContext.get()), SSL_free);
|
m_SSL = shared_ptr<SSL>(SSL_new(m_SSLContext.get()), SSL_free);
|
||||||
|
|
||||||
m_SSLContext.reset();
|
m_SSLContext.reset();
|
||||||
@ -54,7 +52,7 @@ void TlsStream::Start(void)
|
|||||||
<< errinfo_openssl_error(ERR_get_error()));
|
<< errinfo_openssl_error(ERR_get_error()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetClientCertificate())
|
if (!m_SSL)
|
||||||
BOOST_THROW_EXCEPTION(logic_error("No X509 client certificate was specified."));
|
BOOST_THROW_EXCEPTION(logic_error("No X509 client certificate was specified."));
|
||||||
|
|
||||||
if (!m_SSLIndexInitialized) {
|
if (!m_SSLIndexInitialized) {
|
||||||
|
@ -111,7 +111,7 @@ void EndpointManager::AddListener(const String& service)
|
|||||||
{
|
{
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
|
shared_ptr<SSL_CTX> sslContext = m_SSLContext;
|
||||||
|
|
||||||
if (!sslContext)
|
if (!sslContext)
|
||||||
BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddListener()"));
|
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) {
|
void EndpointManager::AddConnection(const String& node, const String& service) {
|
||||||
ObjectLock olock(this);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
shared_ptr<SSL_CTX> sslContext = GetSSLContext();
|
shared_ptr<SSL_CTX> sslContext = m_SSLContext;
|
||||||
|
|
||||||
if (!sslContext)
|
if (!sslContext)
|
||||||
BOOST_THROW_EXCEPTION(logic_error("SSL context is required for AddConnection()"));
|
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);
|
ObjectLock olock(this);
|
||||||
|
|
||||||
String peerAddress = client->GetPeerAddress();
|
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();
|
tlsStream->Start();
|
||||||
|
|
||||||
m_PendingClients.insert(tlsStream);
|
m_PendingClients.insert(tlsStream);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user