summaryrefslogtreecommitdiff
path: root/src/mongo/util/net/asio_message_port.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/net/asio_message_port.cpp')
-rw-r--r--src/mongo/util/net/asio_message_port.cpp46
1 files changed, 5 insertions, 41 deletions
diff --git a/src/mongo/util/net/asio_message_port.cpp b/src/mongo/util/net/asio_message_port.cpp
index 88e37feb2d8..16fab7ea8c1 100644
--- a/src/mongo/util/net/asio_message_port.cpp
+++ b/src/mongo/util/net/asio_message_port.cpp
@@ -54,40 +54,6 @@ const char kGET[] = "GET";
const int kHeaderLen = sizeof(MSGHEADER::Value);
const int kInitialMessageSize = 1024;
-class ASIOPorts {
-public:
- void closeAll(AbstractMessagingPort::Tag skipMask) {
- stdx::lock_guard<stdx::mutex> lock_guard(mutex);
- for (auto&& port : _portSet) {
- if (port->getTag() & skipMask) {
- LOG(3) << "Skip closing connection # " << port->connectionId();
- continue;
- }
- LOG(3) << "Closing connection # " << port->connectionId();
- port->shutdown();
- }
- }
-
- void insert(ASIOMessagingPort* p) {
- stdx::lock_guard<stdx::mutex> lock_guard(mutex);
- _portSet.insert(p);
- }
-
- void erase(ASIOMessagingPort* p) {
- stdx::lock_guard<stdx::mutex> lock_guard(mutex);
- _portSet.erase(p);
- }
-
-private:
- stdx::mutex mutex;
- std::unordered_set<ASIOMessagingPort*> _portSet;
-};
-
-// We "new" this so it will still be around when other automatic global vars are being destructed
-// during termination. TODO: This is an artifact from MessagingPort and should be removed when we
-// decide where to put networking global state.
-ASIOPorts& asioPorts = *(new ASIOPorts());
-
#ifdef MONGO_CONFIG_SSL
struct ASIOSSLContextPair {
ASIOSSLContext server;
@@ -109,10 +75,6 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(ASIOSSLContextSetup, ("SSLManager"))(Initia
} // namespace
-void ASIOMessagingPort::closeSockets(AbstractMessagingPort::Tag skipMask) {
- asioPorts.closeAll(skipMask);
-}
-
ASIOMessagingPort::ASIOMessagingPort(int fd, SockAddr farEnd)
: _service(1),
_timer(_service),
@@ -145,7 +107,6 @@ ASIOMessagingPort::ASIOMessagingPort(int fd, SockAddr farEnd)
farEnd.getType() == AF_UNIX ? 0 : IPPROTO_TCP),
fd) {
#endif // MONGO_CONFIG_SSL
- asioPorts.insert(this);
_getSocket().non_blocking(true);
_remote = HostAndPort(farEnd.getAddr(), farEnd.getPort());
_timer.expires_at(decltype(_timer)::time_point::max());
@@ -177,7 +138,6 @@ ASIOMessagingPort::ASIOMessagingPort(Milliseconds timeout, logger::LogSeverity l
#else
_sock(_service) {
#endif // MONGO_CONFIG_SSL
- asioPorts.insert(this);
if (*_timeout == Milliseconds(0)) {
_timeout = boost::none;
}
@@ -187,7 +147,6 @@ ASIOMessagingPort::ASIOMessagingPort(Milliseconds timeout, logger::LogSeverity l
ASIOMessagingPort::~ASIOMessagingPort() {
shutdown();
- asioPorts.erase(this);
}
void ASIOMessagingPort::setTimeout(Milliseconds millis) {
@@ -502,6 +461,11 @@ void ASIOMessagingPort::say(Message& toSend, int responseTo) {
invariant(!toSend.empty());
toSend.header().setId(nextMessageId());
toSend.header().setResponseToMsgId(responseTo);
+ return say(const_cast<const Message&>(toSend));
+}
+
+void ASIOMessagingPort::say(const Message& toSend) {
+ invariant(!toSend.empty());
auto buf = toSend.buf();
if (buf) {
send(buf, MsgData::ConstView(buf).getLen(), nullptr);