summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2013-03-07 12:36:23 -0500
committerEric Milkie <milkie@10gen.com>2013-03-07 12:36:23 -0500
commit70e051c0480212f80582713da5f0736d12f51de8 (patch)
treec0ce951450e04cdba451e3042a714d1535fa6dfe
parent4884f194b011377c05a0b15aecb803efe6af7234 (diff)
downloadmongo-70e051c0480212f80582713da5f0736d12f51de8.tar.gz
SERVER-8734 use a recursive mutex to work around OpenSSL deadlock
-rw-r--r--src/mongo/util/net/sock.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/util/net/sock.cpp b/src/mongo/util/net/sock.cpp
index 802a9f61854..70d24b9d4e1 100644
--- a/src/mongo/util/net/sock.cpp
+++ b/src/mongo/util/net/sock.cpp
@@ -38,6 +38,8 @@
#endif
#ifdef MONGO_SSL
+#include <boost/thread/recursive_mutex.hpp>
+
#include <openssl/err.h>
#include <openssl/ssl.h>
#endif
@@ -391,7 +393,7 @@ namespace mongo {
static void init() {
while ( (int)_mutex.size() < CRYPTO_num_locks() )
- _mutex.push_back( new SimpleMutex("SSLThreadInfo") );
+ _mutex.push_back( new boost::recursive_mutex );
}
static SSLThreadInfo* get() {
@@ -407,7 +409,10 @@ namespace mongo {
unsigned _id;
static AtomicUInt _next;
- static vector<SimpleMutex*> _mutex;
+ // Note: see SERVER-8734 for why we are using a recursive mutex here.
+ // Once the deadlock fix in OpenSSL is incorporated into most distros of
+ // Linux, this can be changed back to a nonrecursive mutex.
+ static std::vector<boost::recursive_mutex*> _mutex;
static boost::thread_specific_ptr<SSLThreadInfo> _thread;
};
@@ -419,7 +424,7 @@ namespace mongo {
}
AtomicUInt SSLThreadInfo::_next;
- vector<SimpleMutex*> SSLThreadInfo::_mutex;
+ vector<boost::recursive_mutex*> SSLThreadInfo::_mutex;
boost::thread_specific_ptr<SSLThreadInfo> SSLThreadInfo::_thread;