summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/db/SConscript5
-rw-r--r--src/mongo/db/db.cpp3
-rw-r--r--src/mongo/db/dbdirectclient.cpp13
-rw-r--r--src/mongo/db/service_context.h2
-rw-r--r--src/mongo/db/service_context_d.cpp14
-rw-r--r--src/mongo/db/service_context_noop.cpp1
7 files changed, 24 insertions, 15 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 1687378dda5..742c2712d6e 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -279,7 +279,6 @@ mongod = env.Program(
source=[
"db/db.cpp",
"db/mongod_options_init.cpp",
- "db/service_entry_point_mongod.cpp",
] + env.WindowsResourceFile("db/db.rc"),
LIBDEPS=[
'db/assemble_response',
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 0daaca784dd..620ba75bf7f 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -547,7 +547,6 @@ env.Library(
'$BUILD_DIR/mongo/client/clientdriver',
'curop',
'lasterror',
- 'assemble_response',
],
)
@@ -567,9 +566,13 @@ env.Library(
target="service_context_d",
source=[
"service_context_d.cpp",
+ "service_entry_point_mongod.cpp",
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/transport/service_entry_point',
+ '$BUILD_DIR/mongo/transport/transport_layer_common',
+ 'assemble_response',
'concurrency/lock_manager',
'curop',
'storage/storage_engine_lock_file',
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 94cd4bbe97c..980310ec1ef 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -488,9 +488,6 @@ ExitCode _initAndListen(int listenPort) {
options.port = listenPort;
options.ipList = serverGlobalParams.bind_ip;
- globalServiceContext->setServiceEntryPoint(
- stdx::make_unique<ServiceEntryPointMongod>(globalServiceContext));
-
// Create, start, and attach the TL
auto transportLayer = stdx::make_unique<transport::TransportLayerLegacy>(
options, globalServiceContext->getServiceEntryPoint());
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 60a001f534e..46a7d30b0f9 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -32,7 +32,6 @@
#include "mongo/db/dbdirectclient.h"
-#include "mongo/db/assemble_response.h"
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/curop.h"
@@ -40,6 +39,7 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/wire_version.h"
#include "mongo/rpc/get_status_from_command_result.h"
+#include "mongo/transport/service_entry_point.h"
#include "mongo/util/log.h"
namespace mongo {
@@ -119,12 +119,19 @@ QueryOptions DBDirectClient::_lookupAvailableOptions() {
return QueryOptions(DBClientBase::_lookupAvailableOptions() & ~QueryOption_Exhaust);
}
+namespace {
+DbResponse loopbackBuildResponse(OperationContext* const opCtx, Message& toSend) {
+ return opCtx->getServiceContext()->getServiceEntryPoint()->handleRequest(
+ opCtx, toSend, HostAndPort{});
+}
+} // namespace
+
bool DBDirectClient::call(Message& toSend, Message& response, bool assertOk, string* actualServer) {
DirectClientScope directClientScope(_opCtx);
LastError::get(_opCtx->getClient()).startRequest();
CurOp curOp(_opCtx);
- auto dbResponse = assembleResponse(_opCtx, toSend, kHostAndPortForDirectClient);
+ auto dbResponse = loopbackBuildResponse(_opCtx, toSend);
invariant(!dbResponse.response.empty());
response = std::move(dbResponse.response);
@@ -136,7 +143,7 @@ void DBDirectClient::say(Message& toSend, bool isRetry, string* actualServer) {
LastError::get(_opCtx->getClient()).startRequest();
CurOp curOp(_opCtx);
- auto dbResponse = assembleResponse(_opCtx, toSend, kHostAndPortForDirectClient);
+ auto dbResponse = loopbackBuildResponse(_opCtx, toSend);
invariant(dbResponse.response.empty());
}
diff --git a/src/mongo/db/service_context.h b/src/mongo/db/service_context.h
index 566ed7fb650..c4f41bd5651 100644
--- a/src/mongo/db/service_context.h
+++ b/src/mongo/db/service_context.h
@@ -389,7 +389,7 @@ public:
void setPreciseClockSource(std::unique_ptr<ClockSource> newSource);
/**
- * Binds the service entry point implementation to the service context
+ * Binds the service entry point implementation to the service context.
*/
void setServiceEntryPoint(std::unique_ptr<ServiceEntryPoint> sep);
diff --git a/src/mongo/db/service_context_d.cpp b/src/mongo/db/service_context_d.cpp
index f1dd329781b..f3e40ee053b 100644
--- a/src/mongo/db/service_context_d.cpp
+++ b/src/mongo/db/service_context_d.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/service_entry_point_mongod.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/db/storage/storage_engine_lock_file.h"
#include "mongo/db/storage/storage_engine_metadata.h"
@@ -56,14 +57,17 @@
namespace mongo {
namespace {
-
-MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) {
- setGlobalServiceContext(stdx::make_unique<ServiceContextMongoD>());
- auto service = getGlobalServiceContext();
-
+auto makeMongoDServiceContext() {
+ auto service = stdx::make_unique<ServiceContextMongoD>();
+ service->setServiceEntryPoint(stdx::make_unique<ServiceEntryPointMongod>(service.get()));
service->setTickSource(stdx::make_unique<SystemTickSource>());
service->setFastClockSource(stdx::make_unique<SystemClockSource>());
service->setPreciseClockSource(stdx::make_unique<SystemClockSource>());
+ return service;
+}
+
+MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) {
+ setGlobalServiceContext(makeMongoDServiceContext());
return Status::OK();
}
} // namespace
diff --git a/src/mongo/db/service_context_noop.cpp b/src/mongo/db/service_context_noop.cpp
index 42fd30f3f3c..993d7fccfeb 100644
--- a/src/mongo/db/service_context_noop.cpp
+++ b/src/mongo/db/service_context_noop.cpp
@@ -35,7 +35,6 @@
#include "mongo/stdx/memory.h"
namespace mongo {
-
StorageEngine* ServiceContextNoop::getGlobalStorageEngine() {
return NULL;
}