From 1b0e65b0ccd5725f97b0a679ac7f7476a242c66e Mon Sep 17 00:00:00 2001 From: Adam Midvidy Date: Thu, 17 Sep 2015 18:54:05 -0400 Subject: SERVER-20477 reset AsyncOp state before returning it to the pool --- src/mongo/executor/network_interface_asio.h | 2 ++ src/mongo/executor/network_interface_asio_command.cpp | 2 ++ src/mongo/executor/network_interface_asio_operation.cpp | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) (limited to 'src/mongo/executor') diff --git a/src/mongo/executor/network_interface_asio.h b/src/mongo/executor/network_interface_asio.h index c96b649ee97..f2570fcd04f 100644 --- a/src/mongo/executor/network_interface_asio.h +++ b/src/mongo/executor/network_interface_asio.h @@ -259,6 +259,8 @@ private: void setOperationProtocol(rpc::Protocol proto); + void reset(); + private: NetworkInterfaceASIO* const _owner; // Information describing a task enqueued on the NetworkInterface diff --git a/src/mongo/executor/network_interface_asio_command.cpp b/src/mongo/executor/network_interface_asio_command.cpp index 48467e4c0b8..c3bb427f53b 100644 --- a/src/mongo/executor/network_interface_asio_command.cpp +++ b/src/mongo/executor/network_interface_asio_command.cpp @@ -292,6 +292,8 @@ void NetworkInterfaceASIO::_completeOperation(AsyncOp* op, const ResponseStatus& auto conn = std::move(op->_connectionPoolHandle); auto asioConn = static_cast(conn.get()); + ownedOp->reset(); + asioConn->bindAsyncOp(std::move(ownedOp)); if (!resp.isOK()) { asioConn->indicateFailed(resp.getStatus()); diff --git a/src/mongo/executor/network_interface_asio_operation.cpp b/src/mongo/executor/network_interface_asio_operation.cpp index bc783b56e0c..535dc19ba80 100644 --- a/src/mongo/executor/network_interface_asio_operation.cpp +++ b/src/mongo/executor/network_interface_asio_operation.cpp @@ -215,5 +215,21 @@ void NetworkInterfaceASIO::AsyncOp::setOperationProtocol(rpc::Protocol proto) { _operationProtocol = proto; } +void NetworkInterfaceASIO::AsyncOp::reset() { + // We don't reset owner as it never changes + _cbHandle = {}; + _request = {}; + _onFinish = {}; + _connectionPoolHandle = {}; + // We don't reset _connection as we want to reuse it. + // Ditto for _operationProtocol. + _start = {}; + _timeoutAlarm.reset(); + _canceled.store(0u); + _timedOut.store(0u); + _command = boost::none; + // _inSetup should always be false at this point. +} + } // namespace executor } // namespace mongo -- cgit v1.2.1