summaryrefslogtreecommitdiff
path: root/src/mongo/transport
diff options
context:
space:
mode:
authorVishnu Kaushik <vishnu.kaushik@mongodb.com>2019-06-21 14:24:13 -0400
committerJason Chan <jason.chan@10gen.com>2019-08-19 17:07:56 -0400
commit306841443067f947b864c42ca44b11c0ecd1d2e3 (patch)
tree3041d2669fe36081bfd2e9393fed32855c659474 /src/mongo/transport
parent2b397de6f4de5dd130158579cc0e1760121580ad (diff)
downloadmongo-306841443067f947b864c42ca44b11c0ecd1d2e3.tar.gz
SERVER-41482 removed the call to OpMsg::parse and used the exhaustCursorId present with DbResponse
SERVER-41482 added functionality to load DbResponse's exhaustCursorId and exhaustNS in the mock SEP's handleRequest() method. (cherry picked from commit 451d98685a3275b4cfd53164cf323155cbb3260a)
Diffstat (limited to 'src/mongo/transport')
-rw-r--r--src/mongo/transport/service_state_machine.cpp18
-rw-r--r--src/mongo/transport/service_state_machine_test.cpp13
2 files changed, 13 insertions, 18 deletions
diff --git a/src/mongo/transport/service_state_machine.cpp b/src/mongo/transport/service_state_machine.cpp
index 03834d17503..1821f7407ed 100644
--- a/src/mongo/transport/service_state_machine.cpp
+++ b/src/mongo/transport/service_state_machine.cpp
@@ -118,25 +118,9 @@ Message makeExhaustMessage(Message requestMsg, DbResponse* dbresponse) {
return Message();
}
- auto reply = OpMsg::parse(dbresponse->response);
-
- // Check for a non-OK response.
- auto resOk = reply.body["ok"].number();
- if (resOk != 1.0) {
- return Message();
- }
-
- // Check the validity of the 'cursor' object in the response.
- auto cursorObj = reply.body.getObjectField("cursor");
- if (cursorObj.isEmpty()) {
- return Message();
- }
-
// A returned cursor id of '0' indicates that the cursor is exhausted and so the exhaust stream
// should be terminated. Also make sure the cursor namespace is valid.
- auto cursorId = cursorObj.getField("id").numberLong();
- auto cursorNs = cursorObj.getField("ns").str();
- if (cursorId == 0 || cursorNs.empty()) {
+ if (dbresponse->exhaustCursorId == 0 || dbresponse->exhaustNS.empty()) {
return Message();
}
diff --git a/src/mongo/transport/service_state_machine_test.cpp b/src/mongo/transport/service_state_machine_test.cpp
index 72baf66aad1..f10fff2d0ef 100644
--- a/src/mongo/transport/service_state_machine_test.cpp
+++ b/src/mongo/transport/service_state_machine_test.cpp
@@ -88,7 +88,18 @@ public:
if (_uassertInHandler)
uassert(40469, "Synthetic uassert failure", false);
- return DbResponse{res};
+ DbResponse dbResponse;
+ if (OpMsg::isFlagSet(request, OpMsg::kExhaustSupported)) {
+ auto reply = OpMsg::parse(res);
+ auto cursorObj = reply.body.getObjectField("cursor");
+ if (reply.body["ok"].trueValue() && !cursorObj.isEmpty()) {
+ dbResponse.exhaustCursorId = cursorObj.getField("id").numberLong();
+ dbResponse.exhaustNS = cursorObj.getField("ns").String();
+ }
+ }
+ dbResponse.response = res;
+
+ return dbResponse;
}
void endAllSessions(transport::Session::TagMask tags) override {}