diff options
author | samantharitter <samantha.ritter@10gen.com> | 2015-08-04 15:52:38 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2015-08-14 12:27:46 -0400 |
commit | f075019a1dc78f242cb2ff47af641134c6ffbf54 (patch) | |
tree | f8640b160468c2fea53c80e231e4c27b7185c714 /src/mongo/executor/network_interface_asio.cpp | |
parent | a925e2622bd55b852a52b3a9afd1b0cf0f01116c (diff) | |
download | mongo-f075019a1dc78f242cb2ff47af641134c6ffbf54.tar.gz |
SERVER-19359 implement setAlarm() for NetworkInterfaceASIO
Diffstat (limited to 'src/mongo/executor/network_interface_asio.cpp')
-rw-r--r-- | src/mongo/executor/network_interface_asio.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/executor/network_interface_asio.cpp b/src/mongo/executor/network_interface_asio.cpp index d9f7ac41250..b122d76ab87 100644 --- a/src/mongo/executor/network_interface_asio.cpp +++ b/src/mongo/executor/network_interface_asio.cpp @@ -40,6 +40,8 @@ #include "mongo/stdx/memory.h" #include "mongo/util/log.h" #include "mongo/util/net/sock.h" +#include "mongo/util/net/ssl_manager.h" +#include "mongo/util/time_support.h" namespace mongo { namespace executor { @@ -141,7 +143,17 @@ void NetworkInterfaceASIO::cancelCommand(const TaskExecutor::CallbackHandle& cbH } void NetworkInterfaceASIO::setAlarm(Date_t when, const stdx::function<void()>& action) { - MONGO_UNREACHABLE; + // "alarm" must stay alive until it expires, hence the shared_ptr. + auto alarm = std::make_shared<asio::steady_timer>(_io_service, when - now()); + alarm->async_wait([alarm, this, action](std::error_code ec) { + if (!ec) { + return action(); + } else if (ec != asio::error::operation_aborted) { + // When the network interface is shut down, it will cancel all pending + // alarms, raising an "operation_aborted" error here, which we ignore. + warning() << "setAlarm() received an error: " << ec.message(); + } + }); }; bool NetworkInterfaceASIO::inShutdown() const { |