diff options
author | ADAM David Alan Martin <adam.martin@10gen.com> | 2016-12-09 12:26:25 -0500 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2016-12-09 12:26:25 -0500 |
commit | f30f645e4e6acde092d8e0c826201b25ad42eee7 (patch) | |
tree | f9336f2e5894cfce536c21bb5b66199a3519932f /src | |
parent | b5fedd38b03e5d787fc4322a28e12aa38a3d3dc8 (diff) | |
download | mongo-f30f645e4e6acde092d8e0c826201b25ad42eee7.tar.gz |
SERVER-27287: Deduplicate `SetGlobalEnvironment`
Some places defining this initializer were outside of the
anonymous namespace, leading to future potential symbol collisions.
All locations were put into the anonymous namespace.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/service_context_d.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/sorter/sorter_test.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mock.cpp | 3 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp index a677fb394bb..b04012a8e51 100644 --- a/src/mongo/db/service_context_d.cpp +++ b/src/mongo/db/service_context_d.cpp @@ -55,6 +55,7 @@ #include "mongo/util/system_tick_source.h" namespace mongo { +namespace { MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { setGlobalServiceContext(stdx::make_unique<ServiceContextMongoD>()); @@ -65,6 +66,7 @@ MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { service->setPreciseClockSource(stdx::make_unique<SystemClockSource>()); return Status::OK(); } +} // namespace ServiceContextMongoD::ServiceContextMongoD() = default; diff --git a/src/mongo/db/sorter/sorter_test.cpp b/src/mongo/db/sorter/sorter_test.cpp index 1bf02fdcbf3..6a85cbfaef2 100644 --- a/src/mongo/db/sorter/sorter_test.cpp +++ b/src/mongo/db/sorter/sorter_test.cpp @@ -52,11 +52,14 @@ using namespace mongo::sorter; using std::make_shared; using std::pair; +namespace { + // Stub to avoid including the server environment library. MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { setGlobalServiceContext(stdx::make_unique<ServiceContextNoop>()); return Status::OK(); } +} // namespace // // Sorter framework testing utilities diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mock.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mock.cpp index e6460222ec4..83eb5d7d342 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mock.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store_mock.cpp @@ -45,8 +45,11 @@ bool WiredTigerKVEngine::initRsOplogBackgroundThread(StringData ns) { return NamespaceString::oplog(ns); } +namespace { + MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) { setGlobalServiceContext(stdx::make_unique<ServiceContextNoop>()); return Status::OK(); } +} // namespace } // namespace mongo |