summaryrefslogtreecommitdiff
path: root/src/mongo/tools/bridge.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/tools/bridge.cpp')
-rw-r--r--src/mongo/tools/bridge.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp
index e377fae9be8..986114093ed 100644
--- a/src/mongo/tools/bridge.cpp
+++ b/src/mongo/tools/bridge.cpp
@@ -56,6 +56,7 @@
#include "mongo/transport/transport_layer_asio.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/exit.h"
+#include "mongo/util/future.h"
#include "mongo/util/quick_exit.h"
#include "mongo/util/signal_handlers.h"
#include "mongo/util/str.h"
@@ -248,10 +249,12 @@ class ServiceEntryPointBridge final : public ServiceEntryPointImpl {
public:
explicit ServiceEntryPointBridge(ServiceContext* svcCtx) : ServiceEntryPointImpl(svcCtx) {}
- DbResponse handleRequest(OperationContext* opCtx, const Message& request) final;
+ Future<DbResponse> handleRequest(OperationContext* opCtx,
+ const Message& request) noexcept final;
};
-DbResponse ServiceEntryPointBridge::handleRequest(OperationContext* opCtx, const Message& request) {
+Future<DbResponse> ServiceEntryPointBridge::handleRequest(OperationContext* opCtx,
+ const Message& request) noexcept try {
if (request.operation() == dbQuery) {
DbMessage d(request);
QueryMessage q(d);
@@ -344,7 +347,8 @@ DbResponse ServiceEntryPointBridge::handleRequest(OperationContext* opCtx, const
if (!status->isOK()) {
commandReply = StatusWith<BSONObj>(*status);
}
- return {replyBuilder->setCommandReply(std::move(commandReply)).done()};
+ return Future<DbResponse>::makeReady(
+ {replyBuilder->setCommandReply(std::move(commandReply)).done()});
}
@@ -361,7 +365,7 @@ DbResponse ServiceEntryPointBridge::handleRequest(OperationContext* opCtx, const
"remote"_attr = dest,
"source"_attr = source->remote().toString());
source->end();
- return {Message()};
+ return Future<DbResponse>::makeReady({Message()});
// Forward the message to 'dest' with probability '1 - hostSettings.loss'.
case HostSettings::State::kDiscard:
if (dest.nextCanonicalDouble() < hostSettings.loss) {
@@ -381,7 +385,7 @@ DbResponse ServiceEntryPointBridge::handleRequest(OperationContext* opCtx, const
"operation"_attr = networkOpToString(request.operation()),
"hostName"_attr = hostName);
}
- return {Message()};
+ return Future<DbResponse>::makeReady({Message()});
}
// Forward the message to 'dest' after waiting for 'hostSettings.delay'
// milliseconds.
@@ -429,7 +433,7 @@ DbResponse ServiceEntryPointBridge::handleRequest(OperationContext* opCtx, const
"remote"_attr = dest,
"source"_attr = source->remote());
source->end();
- return {Message()};
+ return Future<DbResponse>::makeReady({Message()});
}
// Only support OP_MSG exhaust cursors.
@@ -447,10 +451,13 @@ DbResponse ServiceEntryPointBridge::handleRequest(OperationContext* opCtx, const
// whether this should be run again to receive more responses from the exhaust stream.
// We do not need to set 'nextInvocation' in the DbResponse because mongobridge
// only receives responses but ignores the next request if it is in exhaust mode.
- return {std::move(response), isExhaust};
+ return Future<DbResponse>::makeReady({std::move(response), isExhaust});
} else {
- return {Message()};
+ return Future<DbResponse>::makeReady({Message()});
}
+} catch (const DBException& e) {
+ LOGV2_ERROR(4879804, "Failed to handle request", "error"_attr = redact(e));
+ return e.toStatus();
}
int bridgeMain(int argc, char** argv) {