summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Galtsev <sergey.galtsev@mongodb.com>2021-11-02 21:11:35 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-02 22:14:58 +0000
commit2eaa640caa44332a0cf63b3e69b62a88f1d9c0cd (patch)
tree9223090a787019ad89ee108729f5ab702b87fe48
parent87405e56b1ff812fed4be60ca082d042b1173279 (diff)
downloadmongo-2eaa640caa44332a0cf63b3e69b62a88f1d9c0cd.tar.gz
Revert "SERVER-60503 refactor SSLThreadInfo for easier debugging"
-rw-r--r--src/mongo/util/net/openssl_init.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/mongo/util/net/openssl_init.cpp b/src/mongo/util/net/openssl_init.cpp
index 3bcd9973b90..89e5a1c4498 100644
--- a/src/mongo/util/net/openssl_init.cpp
+++ b/src/mongo/util/net/openssl_init.cpp
@@ -83,31 +83,34 @@ public:
}
static void lockingCallback(int mode, int type, const char* file, int line) {
- const auto m = mutexes.at(type).get();
if (mode & CRYPTO_LOCK) {
- m->lock();
+ mutexes()[type]->lock();
} else {
- m->unlock();
+ mutexes()[type]->unlock();
}
}
static void init() {
- while ((int)mutexes.size() < CRYPTO_num_locks()) {
- mutexes.emplace_back(std::make_unique<stdx::recursive_mutex>());
- }
-
CRYPTO_set_id_callback(&SSLThreadInfo::getID);
CRYPTO_set_locking_callback(&SSLThreadInfo::lockingCallback);
+
+ while ((int)mutexes().size() < CRYPTO_num_locks()) {
+ mutexes().emplace_back(std::make_unique<stdx::recursive_mutex>());
+ }
}
private:
SSLThreadInfo() = delete;
- // History: see SERVER-8734 for why we are using a recursive mutex here.
- // Original plan was to revert to regular mutex when OpenSSL fixes the deadock.
- // Deadlock was fixed in OpenSSL 0.9.8y, however OpenSSL 1.1.1 and later
- // started to use internal locking, so there is no longer a need to revert.
- static std::vector<std::unique_ptr<stdx::recursive_mutex>> mutexes;
+ // 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<std::unique_ptr<stdx::recursive_mutex>>& mutexes() {
+ // Keep the static as a pointer to avoid it ever to be destroyed. It is referenced in the
+ // CallErrRemoveState thread local above.
+ static auto m = new std::vector<std::unique_ptr<stdx::recursive_mutex>>();
+ return *m;
+ }
class ThreadIDManager {
public:
@@ -141,8 +144,6 @@ private:
}
};
-std::vector<std::unique_ptr<stdx::recursive_mutex>> SSLThreadInfo::mutexes;
-
void setupFIPS() {
// Turn on FIPS mode if requested, OPENSSL_FIPS must be defined by the OpenSSL headers
#if defined(MONGO_CONFIG_HAVE_FIPS_MODE_SET)