From 225a2a57350c79a190c13054a038b6c3c559a558 Mon Sep 17 00:00:00 2001 From: Matt Cotter Date: Wed, 27 Jan 2016 16:39:14 -0500 Subject: SERVER-23448 create an ASIO based MessagingPort --- src/mongo/tools/bridge.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/mongo/tools') diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp index 64ff17387e0..e61fd05d9f9 100644 --- a/src/mongo/tools/bridge.cpp +++ b/src/mongo/tools/bridge.cpp @@ -53,6 +53,7 @@ #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" +#include "mongo/util/net/abstract_message_port.h" #include "mongo/util/net/listen.h" #include "mongo/util/net/message.h" #include "mongo/util/exit.h" @@ -86,7 +87,7 @@ boost::optional extractHostInfo(const rpc::RequestInterface& reques class Forwarder { public: - Forwarder(MessagingPort* mp, + Forwarder(AbstractMessagingPort* mp, stdx::mutex* settingsMutex, HostSettingsMap* settings, int64_t seed) @@ -114,7 +115,7 @@ public: warning() << "Unable to establish connection to " << mongoBridgeGlobalParams.destUri << " after " << elapsed << " seconds: " << status; - log() << "end connection " << _mp->psock->remoteString(); + log() << "end connection " << _mp->remote().toString(); _mp->shutdown(); return; } @@ -132,7 +133,7 @@ public: try { request.reset(); if (!_mp->recv(request)) { - log() << "end connection " << _mp->psock->remoteString(); + log() << "end connection " << _mp->remote().toString(); _mp->shutdown(); break; } @@ -183,7 +184,7 @@ public: // Close the connection to 'dest'. case HostSettings::State::kHangUp: log() << "Rejecting connection from " << host->toString() - << ", end connection " << _mp->psock->remoteString(); + << ", end connection " << _mp->remote().toString(); _mp->shutdown(); return; // Forward the message to 'dest' with probability '1 - hostSettings.loss'. @@ -214,7 +215,7 @@ public: // If there's nothing to respond back to '_mp' with, then close the connection. if (response.empty()) { log() << "Received an empty response, end connection " - << _mp->psock->remoteString(); + << _mp->remote().toString(); _mp->shutdown(); break; } @@ -228,7 +229,7 @@ public: // connections from 'host', then do so now. if (hostSettings.state == HostSettings::State::kHangUp) { log() << "Closing connection from " << host->toString() - << ", end connection " << _mp->psock->remoteString(); + << ", end connection " << _mp->remote().toString(); _mp->shutdown(); break; } @@ -259,7 +260,7 @@ public: } } catch (const DBException& ex) { error() << "Caught DBException in Forwarder: " << ex << ", end connection " - << _mp->psock->remoteString(); + << _mp->remote().toString(); _mp->shutdown(); break; } catch (...) { @@ -303,7 +304,7 @@ private: return {}; } - MessagingPort* _mp; + AbstractMessagingPort* _mp; stdx::mutex* _settingsMutex; HostSettingsMap* _settings; @@ -319,7 +320,7 @@ public: log() << "Setting random seed: " << mongoBridgeGlobalParams.seed; } - void acceptedMP(MessagingPort* mp) final { + void accepted(AbstractMessagingPort* mp) override final { { stdx::lock_guard lk(_portsMutex); if (_inShutdown.load()) { @@ -343,7 +344,7 @@ public: private: stdx::mutex _portsMutex; - std::set _ports; + std::set _ports; AtomicWord _inShutdown{false}; stdx::mutex _settingsMutex; -- cgit v1.2.1