From 6f6df7ff93c92f7917d46a0764d193d26f2ea9e9 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 8 Jun 2017 21:07:17 -0400 Subject: 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. --- src/mongo/db/assemble_response.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src/mongo/db/assemble_response.cpp') diff --git a/src/mongo/db/assemble_response.cpp b/src/mongo/db/assemble_response.cpp index 9d0921237bb..06ac6c090c6 100644 --- a/src/mongo/db/assemble_response.cpp +++ b/src/mongo/db/assemble_response.cpp @@ -59,8 +59,6 @@ namespace mongo { -const HostAndPort kHostAndPortForDirectClient("0.0.0.0", 0); - MONGO_FP_DECLARE(rsStopGetMore); namespace { @@ -370,8 +368,9 @@ DbResponse receivedGetMore(OperationContext* opCtx, } } // namespace +} // namespace mongo -DbResponse assembleResponse(OperationContext* opCtx, const Message& m, const HostAndPort& remote) { +mongo::DbResponse mongo::assembleResponse(OperationContext* opCtx, const Message& m) { // before we lock... NetworkOp op = m.operation(); bool isCommand = false; @@ -456,16 +455,14 @@ DbResponse assembleResponse(OperationContext* opCtx, const Message& m, const Hos currentOp.done(); shouldLogOpDebug = true; } else { - if (remote != kHostAndPortForDirectClient) { + if (!opCtx->getClient()->isInDirectClient()) { const ShardedConnectionInfo* connInfo = ShardedConnectionInfo::get(&c, false); uassert(18663, str::stream() << "legacy writeOps not longer supported for " << "versioned connections, ns: " << nsString.ns() << ", op: " - << networkOpToString(op) - << ", remote: " - << remote.toString(), + << networkOpToString(op), connInfo == NULL); } @@ -531,5 +528,3 @@ DbResponse assembleResponse(OperationContext* opCtx, const Message& m, const Hos recordCurOpMetrics(opCtx); return dbresponse; } - -} // namespace mongo -- cgit v1.2.1