diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceSSL/OpenSSLPluginI.cpp | 31 | ||||
-rw-r--r-- | cpp/src/IceSSL/OpenSSLPluginI.h | 10 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslClientTransceiver.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslServerTransceiver.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslTransceiver.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceSSL/SslTransceiver.h | 1 |
6 files changed, 49 insertions, 0 deletions
diff --git a/cpp/src/IceSSL/OpenSSLPluginI.cpp b/cpp/src/IceSSL/OpenSSLPluginI.cpp index eb4091026b3..a5aced06898 100644 --- a/cpp/src/IceSSL/OpenSSLPluginI.cpp +++ b/cpp/src/IceSSL/OpenSSLPluginI.cpp @@ -153,6 +153,9 @@ IceSSL::SslLockKeeper::~SslLockKeeper() // PluginI implementation // +IceUtil::Mutex IceSSL::OpenSSLPluginI::_threadIdCacheMutex; +std::vector<unsigned long> IceSSL::OpenSSLPluginI::_threadIdCache; + // // Public Methods // @@ -179,6 +182,7 @@ IceSSL::OpenSSLPluginI::OpenSSLPluginI(const ProtocolPluginFacadePtr& protocolPl IceSSL::OpenSSLPluginI::~OpenSSLPluginI() { + unregisterThreads(); ERR_free_strings(); } @@ -820,3 +824,30 @@ IceSSL::OpenSSLPluginI::loadTempCerts(TempCertificates& tempCerts) iDHP++; } } + +// +// Note: These two methods are used to remember each thread that uses the IceSSL plugin, +// and then clean up the thread-specific error queue on plugin shutdown. +// + +void +IceSSL::OpenSSLPluginI::registerThread() +{ + unsigned long threadID = idFunction(); + + IceUtil::Mutex::Lock sync(_threadIdCacheMutex); + + if(find(_threadIdCache.begin(), _threadIdCache.end(), threadID) == _threadIdCache.end()) + { + _threadIdCache.push_back(threadID); + } +} + +void +IceSSL::OpenSSLPluginI::unregisterThreads() +{ + IceUtil::Mutex::Lock sync(_threadIdCacheMutex); + + for_each(_threadIdCache.begin(), _threadIdCache.end(), ERR_remove_state); +} + diff --git a/cpp/src/IceSSL/OpenSSLPluginI.h b/cpp/src/IceSSL/OpenSSLPluginI.h index bd4a5036daf..d55ff57cfa1 100644 --- a/cpp/src/IceSSL/OpenSSLPluginI.h +++ b/cpp/src/IceSSL/OpenSSLPluginI.h @@ -120,6 +120,16 @@ private: // Load the temporary (ephemeral) certificates for Server operations. void loadTempCerts(TempCertificates&); + + friend class SslTransceiver; + friend class SslClientTransceiver; + friend class SslServerTransceiver; + + static IceUtil::Mutex _threadIdCacheMutex; + static std::vector<unsigned long> _threadIdCache; + + void registerThread(); + void unregisterThreads(); }; } diff --git a/cpp/src/IceSSL/SslClientTransceiver.cpp b/cpp/src/IceSSL/SslClientTransceiver.cpp index 3f59872d8b0..96ee5a1880c 100644 --- a/cpp/src/IceSSL/SslClientTransceiver.cpp +++ b/cpp/src/IceSSL/SslClientTransceiver.cpp @@ -32,6 +32,8 @@ IceSSL::SslClientTransceiver::write(Buffer& buf, int timeout) { assert(_fd != INVALID_SOCKET); + _plugin->registerThread(); + int totalBytesWritten = 0; int bytesWritten = 0; diff --git a/cpp/src/IceSSL/SslServerTransceiver.cpp b/cpp/src/IceSSL/SslServerTransceiver.cpp index 9077dfa9342..7856aa5be15 100644 --- a/cpp/src/IceSSL/SslServerTransceiver.cpp +++ b/cpp/src/IceSSL/SslServerTransceiver.cpp @@ -34,6 +34,8 @@ IceSSL::SslServerTransceiver::write(Buffer& buf, int timeout) { assert(_fd != INVALID_SOCKET); + _plugin->registerThread(); + int totalBytesWritten = 0; int bytesWritten = 0; diff --git a/cpp/src/IceSSL/SslTransceiver.cpp b/cpp/src/IceSSL/SslTransceiver.cpp index 39203caa8c0..a4f8ced9c08 100644 --- a/cpp/src/IceSSL/SslTransceiver.cpp +++ b/cpp/src/IceSSL/SslTransceiver.cpp @@ -107,6 +107,8 @@ IceSSL::SslTransceiver::read(Buffer& buf, int timeout) { assert(_fd != INVALID_SOCKET); + _plugin->registerThread(); + int packetSize = buf.b.end() - buf.i; int totalBytesRead = 0; int bytesRead; @@ -931,6 +933,7 @@ IceSSL::SslTransceiver::SslTransceiver(const OpenSSLPluginIPtr& plugin, const CertificateVerifierPtr& certificateVerifier, SSL* sslConnection) : _sslConnection(sslConnection), + _plugin(plugin), _traceLevels(plugin->getTraceLevels()), _logger(plugin->getLogger()), _fd(fd), diff --git a/cpp/src/IceSSL/SslTransceiver.h b/cpp/src/IceSSL/SslTransceiver.h index be7be5b1548..bc832d3c5b7 100644 --- a/cpp/src/IceSSL/SslTransceiver.h +++ b/cpp/src/IceSSL/SslTransceiver.h @@ -198,6 +198,7 @@ protected: SslTransceiver(const OpenSSLPluginIPtr&, SOCKET, const IceSSL::CertificateVerifierPtr&, SSL*); virtual ~SslTransceiver(); + OpenSSLPluginIPtr _plugin; TraceLevelsPtr _traceLevels; Ice::LoggerPtr _logger; SOCKET _fd; |