summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/SChannelEngine.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2018-10-26 18:57:46 +0200
committerJose <jose@zeroc.com>2018-10-26 18:58:28 +0200
commit1e28d6a3fe11c0d282757b465b36118c4ff0f877 (patch)
tree9016e6ccdc3fe8e87be00b71983825550657f9ab /cpp/src/IceSSL/SChannelEngine.cpp
parentBetter detect debian derivatives (diff)
downloadice-1e28d6a3fe11c0d282757b465b36118c4ff0f877.tar.bz2
ice-1e28d6a3fe11c0d282757b465b36118c4ff0f877.tar.xz
ice-1e28d6a3fe11c0d282757b465b36118c4ff0f877.zip
Use a global mutex for SChannel initialization
Close #242
Diffstat (limited to 'cpp/src/IceSSL/SChannelEngine.cpp')
-rw-r--r--cpp/src/IceSSL/SChannelEngine.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/cpp/src/IceSSL/SChannelEngine.cpp b/cpp/src/IceSSL/SChannelEngine.cpp
index 63b4db62030..51ddfd1856b 100644
--- a/cpp/src/IceSSL/SChannelEngine.cpp
+++ b/cpp/src/IceSSL/SChannelEngine.cpp
@@ -19,6 +19,7 @@
#include <IceUtil/StringUtil.h>
#include <IceUtil/FileUtil.h>
+#include <IceUtil/MutexPtrLock.h>
#include <Ice/UUID.h>
#include <wincrypt.h>
@@ -54,6 +55,26 @@ Shared* SChannel::upCast(SChannel::SSLEngine* p)
namespace
{
+IceUtil::Mutex* globalMutex;
+
+class Init
+{
+public:
+
+ Init()
+ {
+ globalMutex = new IceUtil::Mutex;
+ }
+
+ ~Init()
+ {
+ delete globalMutex;
+ globalMutex = 0;
+ }
+};
+
+Init init;
+
void
addMatchingCertificates(HCERTSTORE source, HCERTSTORE target, DWORD findType, const void* findParam)
{
@@ -580,6 +601,17 @@ SChannel::SSLEngine::SSLEngine(const CommunicatorPtr& communicator) :
void
SChannel::SSLEngine::initialize()
{
+ //
+ // BUGFIX: we use a global mutex for the initialization of SChannel to
+ // avoid crashes ocurring with last SChannel updates see:
+ // https://github.com/zeroc-ice/ice/issues/242
+ //
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
+
+ //
+ // We still have to acquire the instance mutex because it is used by the base
+ // class to access _initialized data member.
+ //
Mutex::Lock lock(_mutex);
if(_initialized)
{