summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbdirectclient.cpp
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/db/dbdirectclient.cpp
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/db/dbdirectclient.cpp')
-rw-r--r--src/mongo/db/dbdirectclient.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 60a001f534e..f7b71b88668 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,18 @@ QueryOptions DBDirectClient::_lookupAvailableOptions() {
return QueryOptions(DBClientBase::_lookupAvailableOptions() & ~QueryOption_Exhaust);
}
+namespace {
+DbResponse loopbackBuildResponse(OperationContext* const opCtx, Message& toSend) {
+ return opCtx->getServiceContext()->getServiceEntryPoint()->handleRequest(opCtx, toSend);
+}
+} // 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 +142,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());
}