diff options
author | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2019-06-21 14:24:13 -0400 |
---|---|---|
committer | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2019-06-21 14:25:14 -0400 |
commit | 451d98685a3275b4cfd53164cf323155cbb3260a (patch) | |
tree | b49b84329b28beda2409303867fdffac77765ff6 /src | |
parent | e5c4b9d476475f994c47938b3933759ea9b91b28 (diff) | |
download | mongo-451d98685a3275b4cfd53164cf323155cbb3260a.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.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/transport/service_state_machine.cpp | 18 | ||||
-rw-r--r-- | src/mongo/transport/service_state_machine_test.cpp | 13 |
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 4e073280d00..6fe9323a923 100644 --- a/src/mongo/transport/service_state_machine.cpp +++ b/src/mongo/transport/service_state_machine.cpp @@ -119,25 +119,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 c132d39d548..4c96ea13b01 100644 --- a/src/mongo/transport/service_state_machine_test.cpp +++ b/src/mongo/transport/service_state_machine_test.cpp @@ -89,7 +89,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 {} |