Fix a deadlock in TlsStream::Read / TlsStream::Close

fixes #8124
This commit is contained in:
Gunnar Beutner 2014-12-19 12:07:06 +01:00
parent 06052c0539
commit 28d7051aed
2 changed files with 10 additions and 3 deletions

View File

@ -139,7 +139,7 @@ void TlsStream::Handshake(void)
} catch (const std::exception&) {}
continue;
case SSL_ERROR_ZERO_RETURN:
Close();
CloseUnlocked();
return;
default:
msgbuf << "SSL_do_handshake() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
@ -197,7 +197,7 @@ size_t TlsStream::Read(void *buffer, size_t count)
} catch (const std::exception&) {}
continue;
case SSL_ERROR_ZERO_RETURN:
Close();
CloseUnlocked();
return count - left;
default:
if (ERR_peek_error() != 0) {
@ -251,7 +251,7 @@ void TlsStream::Write(const void *buffer, size_t count)
} catch (const std::exception&) {}
continue;
case SSL_ERROR_ZERO_RETURN:
Close();
CloseUnlocked();
return;
default:
if (ERR_peek_error() != 0) {
@ -276,6 +276,11 @@ void TlsStream::Close(void)
{
boost::mutex::scoped_lock alock(m_IOActionLock);
CloseUnlocked();
}
void TlsStream::CloseUnlocked(void)
{
m_Eof = true;
for (int i = 0; i < 5; i++) {

View File

@ -67,6 +67,8 @@ private:
static int m_SSLIndex;
static bool m_SSLIndexInitialized;
void CloseUnlocked(void);
static int ValidateCertificate(int preverify_ok, X509_STORE_CTX *ctx);
static void NullCertificateDeleter(X509 *certificate);
};