diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2020-07-16 16:29:41 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-29 19:06:24 +0000 |
commit | 58283ca178782c4d1c4a4d2acd4313f6f6f86fd5 (patch) | |
tree | 179676923b4a6c254f671c79b710decfecc7b21e /src/mongo/embedded | |
parent | 3cf2bd6b2b75bf6af63b07ccf60cba120627f4b2 (diff) | |
download | mongo-58283ca178782c4d1c4a4d2acd4313f6f6f86fd5.tar.gz |
SERVER-49157 Initialize WireSpec during MONGO_INITIALIZER
Diffstat (limited to 'src/mongo/embedded')
-rw-r--r-- | src/mongo/embedded/embedded.cpp | 14 | ||||
-rw-r--r-- | src/mongo/embedded/embedded_ismaster.cpp | 5 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/mongo/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp index 8adea8014dd..6c88524684b 100644 --- a/src/mongo/embedded/embedded.cpp +++ b/src/mongo/embedded/embedded.cpp @@ -34,6 +34,7 @@ #include "mongo/embedded/embedded.h" #include "mongo/base/initializer.h" +#include "mongo/base/status.h" #include "mongo/config.h" #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/catalog/collection_impl.h" @@ -83,19 +84,18 @@ namespace mongo { namespace embedded { namespace { -void initWireSpec() { - WireSpec& spec = WireSpec::instance(); - +MONGO_INITIALIZER_WITH_PREREQUISITES(WireSpec, ("EndStartupOptionHandling"))(InitializerContext*) { // The featureCompatibilityVersion behavior defaults to the downgrade behavior while the // in-memory version is unset. - + WireSpec::Specification spec; spec.incomingInternalClient.minWireVersion = RELEASE_2_4_AND_BEFORE; spec.incomingInternalClient.maxWireVersion = LATEST_WIRE_VERSION; - spec.outgoing.minWireVersion = RELEASE_2_4_AND_BEFORE; spec.outgoing.maxWireVersion = LATEST_WIRE_VERSION; - spec.isInternalClient = true; + + WireSpec::instance().initialize(std::move(spec)); + return Status::OK(); } // Noop, to fulfill dependencies for other initializers. @@ -203,8 +203,6 @@ ServiceContext* initialize(const char* yaml_config) { // Make sure current thread have no client set in thread_local when we leave this function auto clientGuard = makeGuard([] { Client::releaseCurrent(); }); - initWireSpec(); - auto serviceContext = getGlobalServiceContext(); serviceContext->setServiceEntryPoint(std::make_unique<ServiceEntryPointEmbedded>()); diff --git a/src/mongo/embedded/embedded_ismaster.cpp b/src/mongo/embedded/embedded_ismaster.cpp index 6faa4b4e891..b304a7a9148 100644 --- a/src/mongo/embedded/embedded_ismaster.cpp +++ b/src/mongo/embedded/embedded_ismaster.cpp @@ -68,6 +68,7 @@ public: const BSONObj& cmdObj, BSONObjBuilder& result) { + auto wireSpec = WireSpec::instance().get(); auto& clientMetadataIsMasterState = ClientMetadataIsMasterState::get(opCtx->getClient()); bool seenIsMaster = clientMetadataIsMasterState.hasSeenIsMaster(); if (!seenIsMaster) { @@ -101,8 +102,8 @@ public: result.append("logicalSessionTimeoutMinutes", localLogicalSessionTimeoutMinutes); result.appendNumber("connectionId", opCtx->getClient()->getConnectionId()); - result.append("minWireVersion", WireSpec::instance().incomingExternalClient.minWireVersion); - result.append("maxWireVersion", WireSpec::instance().incomingExternalClient.maxWireVersion); + result.append("minWireVersion", wireSpec->incomingExternalClient.minWireVersion); + result.append("maxWireVersion", wireSpec->incomingExternalClient.maxWireVersion); result.append("readOnly", storageGlobalParams.readOnly); |