summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Wangensteen <george.wangensteen@mongodb.com>2021-08-05 16:32:55 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-05 16:43:42 +0000
commitd9f44b62d17205d90ee9d426044c155951fabb11 (patch)
treeb88f2ddf52d77e41314d01ea569c51ccdd04bc1b
parent8157ede4a9ca52c52fba9627f1f718e30153d7ce (diff)
downloadmongo-d9f44b62d17205d90ee9d426044c155951fabb11.tar.gz
SERVER-49435 Make NetworkInterfaceTL::ExhaustCommandState::sendRequest handle exceptions
(cherry picked from commit 32d4d90cb12b46a57101b5de4e9ba08b5ab50c9e)
-rw-r--r--src/mongo/executor/network_interface_tl.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mongo/executor/network_interface_tl.cpp b/src/mongo/executor/network_interface_tl.cpp
index 7703edd6430..f9474922bc5 100644
--- a/src/mongo/executor/network_interface_tl.cpp
+++ b/src/mongo/executor/network_interface_tl.cpp
@@ -870,7 +870,9 @@ auto NetworkInterfaceTL::ExhaustCommandState::make(NetworkInterfaceTL* interface
}
Future<RemoteCommandResponse> NetworkInterfaceTL::ExhaustCommandState::sendRequest(
- std::shared_ptr<RequestState> requestState) {
+ std::shared_ptr<RequestState> requestState) try {
+ auto [promise, future] = makePromiseFuture<RemoteCommandResponse>();
+ finalResponsePromise = std::move(promise);
setTimer();
requestState->getClient(requestState->conn)
@@ -880,23 +882,21 @@ Future<RemoteCommandResponse> NetworkInterfaceTL::ExhaustCommandState::sendReque
continueExhaustRequest(std::move(requestState), swResponse);
});
- auto [promise, future] = makePromiseFuture<RemoteCommandResponse>();
- finalResponsePromise = std::move(promise);
return std::move(future).then([this](const auto& finalResponse) { return finalResponse; });
+} catch (const DBException& ex) {
+ return ex.toStatus();
}
void NetworkInterfaceTL::ExhaustCommandState::fulfillFinalPromise(
- StatusWith<RemoteCommandOnAnyResponse> response) {
- auto status = !response.getStatus().isOK()
- ? response.getStatus()
- : getStatusFromCommandResult(response.getValue().data);
-
- if (!status.isOK()) {
- promise.setError(status);
- return;
- }
-
- promise.emplaceValue();
+ StatusWith<RemoteCommandOnAnyResponse> swr) {
+ promise.setFrom([&] {
+ if (!swr.isOK())
+ return swr.getStatus();
+ auto response = swr.getValue();
+ if (!response.isOK())
+ return response.status;
+ return getStatusFromCommandResult(response.data);
+ }());
}
void NetworkInterfaceTL::ExhaustCommandState::continueExhaustRequest(