summaryrefslogtreecommitdiff
path: root/src/mongo/transport
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2017-06-08 21:07:17 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2017-06-08 21:07:17 -0400
commit6f6df7ff93c92f7917d46a0764d193d26f2ea9e9 (patch)
treed4a40226bb4e075587a6996d84c09495e53f404f /src/mongo/transport
parent1c56f5dd262111f921203d403f54fedb18772792 (diff)
downloadmongo-6f6df7ff93c92f7917d46a0764d193d26f2ea9e9.tar.gz
SERVER-29305 `DBDirectClient::call` uses OpContext
Presently it directly calls `assembleResponse`, which is responsible for a cyclic dependency. This functionality is available through the `ServiceContext` mechanism, and thus needn't directly use `assembleResponse`. The `ServiceEntryPoint` member of `ServiceContext` is set through a setter, which isn't always called, so we initialize the global entry through a factory function. This also removes the superfluous argument for `HostAndPort`, as that was used to track whether the call was made from within the `DbDirectClient` object itself or from the network -- a separate bit in the `OperationContext` indicates that state.
Diffstat (limited to 'src/mongo/transport')
-rw-r--r--src/mongo/transport/service_entry_point.h4
-rw-r--r--src/mongo/transport/service_entry_point_mock.cpp6
-rw-r--r--src/mongo/transport/service_entry_point_mock.h4
-rw-r--r--src/mongo/transport/service_state_machine.cpp2
-rw-r--r--src/mongo/transport/service_state_machine_test.cpp4
-rw-r--r--src/mongo/transport/transport_layer_legacy_test.cpp4
6 files changed, 7 insertions, 17 deletions
diff --git a/src/mongo/transport/service_entry_point.h b/src/mongo/transport/service_entry_point.h
index f9f82ed3273..b03bb65825a 100644
--- a/src/mongo/transport/service_entry_point.h
+++ b/src/mongo/transport/service_entry_point.h
@@ -55,9 +55,7 @@ public:
/**
* Processes a request and fills out a DbResponse.
*/
- virtual DbResponse handleRequest(OperationContext* opCtx,
- const Message& request,
- const HostAndPort& client) = 0;
+ virtual DbResponse handleRequest(OperationContext* opCtx, const Message& request) = 0;
protected:
ServiceEntryPoint() = default;
diff --git a/src/mongo/transport/service_entry_point_mock.cpp b/src/mongo/transport/service_entry_point_mock.cpp
index 243ebfbec94..0cc465aff92 100644
--- a/src/mongo/transport/service_entry_point_mock.cpp
+++ b/src/mongo/transport/service_entry_point_mock.cpp
@@ -74,7 +74,7 @@ void ServiceEntryPointMock::run(transport::SessionHandle session) {
break;
}
- auto resp = handleRequest(nullptr, inMessage, session->remote());
+ auto resp = handleRequest(nullptr, inMessage);
// sinkMessage()
if (!session->sinkMessage(resp.response).wait().isOK()) {
@@ -83,9 +83,7 @@ void ServiceEntryPointMock::run(transport::SessionHandle session) {
}
}
-DbResponse ServiceEntryPointMock::handleRequest(OperationContext* opCtx,
- const Message& request,
- const HostAndPort& client) {
+DbResponse ServiceEntryPointMock::handleRequest(OperationContext* opCtx, const Message& request) {
// Need to set up our { ok : 1 } response.
BufBuilder b{};
diff --git a/src/mongo/transport/service_entry_point_mock.h b/src/mongo/transport/service_entry_point_mock.h
index 94f011d9f3e..58c6149bf7d 100644
--- a/src/mongo/transport/service_entry_point_mock.h
+++ b/src/mongo/transport/service_entry_point_mock.h
@@ -65,9 +65,7 @@ public:
*/
void startSession(transport::SessionHandle session) override;
- DbResponse handleRequest(OperationContext* opCtx,
- const Message& request,
- const HostAndPort& client) override;
+ DbResponse handleRequest(OperationContext* opCtx, const Message& request) override;
private:
void run(transport::SessionHandle session);
diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp
index 7af9171426f..e573dc74ec8 100644
--- a/src/mongo/transport/service_state_machine.cpp
+++ b/src/mongo/transport/service_state_machine.cpp
@@ -165,7 +165,7 @@ void ServiceStateMachine::processMessage() {
// The handleRequest is implemented in a subclass for mongod/mongos and actually all the
// database work for this request.
- DbResponse dbresponse = _sep->handleRequest(opCtx.get(), _inMessage, session()->remote());
+ DbResponse dbresponse = _sep->handleRequest(opCtx.get(), _inMessage);
// opCtx must be destroyed here so that the operation cannot show
// up in currentOp results after the response reaches the client
diff --git a/src/mongo/transport/service_state_machine_test.cpp b/src/mongo/transport/service_state_machine_test.cpp
index 2e5dd2c8d13..cdd2f0660b9 100644
--- a/src/mongo/transport/service_state_machine_test.cpp
+++ b/src/mongo/transport/service_state_machine_test.cpp
@@ -56,9 +56,7 @@ public:
void startSession(transport::SessionHandle session) override {}
- DbResponse handleRequest(OperationContext* opCtx,
- const Message& request,
- const HostAndPort& client) override {
+ DbResponse handleRequest(OperationContext* opCtx, const Message& request) override {
log() << "In handleRequest";
_ranHandler = true;
ASSERT_TRUE(haveClient());
diff --git a/src/mongo/transport/transport_layer_legacy_test.cpp b/src/mongo/transport/transport_layer_legacy_test.cpp
index 286696b4d6c..90cce0223e3 100644
--- a/src/mongo/transport/transport_layer_legacy_test.cpp
+++ b/src/mongo/transport/transport_layer_legacy_test.cpp
@@ -47,9 +47,7 @@ public:
tll->end(session);
}
- DbResponse handleRequest(OperationContext* opCtx,
- const Message& request,
- const HostAndPort& client) override {
+ DbResponse handleRequest(OperationContext* opCtx, const Message& request) override {
MONGO_UNREACHABLE;
}