From 4152b569c0c03a53c96518877d934f3e1f08d8f4 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Wed, 19 Nov 2014 17:33:57 +0100 Subject: [PATCH] fixed GH #500: SSLManager causes a crash (use AtomicCounter, remove static Mutex) --- Crypto/include/Poco/Crypto/OpenSSLInitializer.h | 4 ++-- Crypto/src/OpenSSLInitializer.cpp | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Crypto/include/Poco/Crypto/OpenSSLInitializer.h b/Crypto/include/Poco/Crypto/OpenSSLInitializer.h index fc57d9717..868530062 100644 --- a/Crypto/include/Poco/Crypto/OpenSSLInitializer.h +++ b/Crypto/include/Poco/Crypto/OpenSSLInitializer.h @@ -22,6 +22,7 @@ #include "Poco/Crypto/Crypto.h" #include "Poco/Mutex.h" +#include "Poco/AtomicCounter.h" #include #include #if defined(OPENSSL_FIPS) && OPENSSL_VERSION_NUMBER < 0x010001000L @@ -82,8 +83,7 @@ protected: private: static Poco::FastMutex* _mutexes; - static Poco::FastMutex _mutex; - static int _rc; + static Poco::AtomicCounter _rc; }; diff --git a/Crypto/src/OpenSSLInitializer.cpp b/Crypto/src/OpenSSLInitializer.cpp index 325c4a416..28ecd115d 100644 --- a/Crypto/src/OpenSSLInitializer.cpp +++ b/Crypto/src/OpenSSLInitializer.cpp @@ -35,8 +35,7 @@ namespace Crypto { Poco::FastMutex* OpenSSLInitializer::_mutexes(0); -Poco::FastMutex OpenSSLInitializer::_mutex; -int OpenSSLInitializer::_rc(0); +Poco::AtomicCounter OpenSSLInitializer::_rc; OpenSSLInitializer::OpenSSLInitializer() @@ -60,8 +59,6 @@ OpenSSLInitializer::~OpenSSLInitializer() void OpenSSLInitializer::initialize() { - Poco::FastMutex::ScopedLock lock(_mutex); - if (++_rc == 1) { #if OPENSSL_VERSION_NUMBER >= 0x0907000L @@ -98,8 +95,6 @@ void OpenSSLInitializer::initialize() void OpenSSLInitializer::uninitialize() { - Poco::FastMutex::ScopedLock lock(_mutex); - if (--_rc == 0) { EVP_cleanup();