diff options
author | samantharitter <samantha.ritter@10gen.com> | 2016-10-05 16:08:57 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2016-10-06 17:24:08 -0400 |
commit | 3e343542c410515d1007e60d73402271b4be910d (patch) | |
tree | 46afb000f393cde95c0c4b63bf38766ff366e697 | |
parent | 1a5ba129ab68af8975581f074803aaf3acaeb316 (diff) | |
download | mongo-3e343542c410515d1007e60d73402271b4be910d.tar.gz |
SERVER-26477 Use non-throwing variant of asio::basic_socket::cancel
-rw-r--r-- | src/mongo/executor/async_secure_stream.cpp | 2 | ||||
-rw-r--r-- | src/mongo/executor/async_stream.cpp | 2 | ||||
-rw-r--r-- | src/mongo/executor/async_stream_common.cpp | 7 | ||||
-rw-r--r-- | src/mongo/executor/async_stream_common.h | 10 |
4 files changed, 16 insertions, 5 deletions
diff --git a/src/mongo/executor/async_secure_stream.cpp b/src/mongo/executor/async_secure_stream.cpp index d1e4f2bfc23..2d3697561ba 100644 --- a/src/mongo/executor/async_secure_stream.cpp +++ b/src/mongo/executor/async_secure_stream.cpp @@ -108,7 +108,7 @@ void AsyncSecureStream::_handleHandshake(std::error_code ec, const std::string& } void AsyncSecureStream::cancel() { - cancelStream(&_stream.lowest_layer(), _connected); + cancelStream(&_stream.lowest_layer()); } bool AsyncSecureStream::isOpen() { diff --git a/src/mongo/executor/async_stream.cpp b/src/mongo/executor/async_stream.cpp index 60a805d2753..075a9094dd4 100644 --- a/src/mongo/executor/async_stream.cpp +++ b/src/mongo/executor/async_stream.cpp @@ -84,7 +84,7 @@ void AsyncStream::read(asio::mutable_buffer buffer, StreamHandler&& streamHandle } void AsyncStream::cancel() { - cancelStream(&_stream, _connected); + cancelStream(&_stream); } bool AsyncStream::isOpen() { diff --git a/src/mongo/executor/async_stream_common.cpp b/src/mongo/executor/async_stream_common.cpp index f029607b472..a1cd69ff49f 100644 --- a/src/mongo/executor/async_stream_common.cpp +++ b/src/mongo/executor/async_stream_common.cpp @@ -39,7 +39,12 @@ namespace executor { void logCloseFailed(std::error_code ec) { invariant(ec); - log() << "failed to close stream: " << ec.message(); + log() << "Failed to close stream: " << ec.message(); +} + +void logCancelFailed(std::error_code ec) { + invariant(ec); + log() << "Failed to cancel stream: " << ec.message(); } void logFailureInSetStreamNonBlocking(std::error_code ec) { diff --git a/src/mongo/executor/async_stream_common.h b/src/mongo/executor/async_stream_common.h index 6f7bd5eff63..93da9f32786 100644 --- a/src/mongo/executor/async_stream_common.h +++ b/src/mongo/executor/async_stream_common.h @@ -80,9 +80,15 @@ void readStream(ASIOStream* stream, strand->wrap(std::forward<Handler>(handler))); } +void logCancelFailed(std::error_code ec); + template <typename ASIOStream> -void cancelStream(ASIOStream* stream, bool connected) { - stream->cancel(); +void cancelStream(ASIOStream* stream) { + std::error_code ec; + stream->cancel(ec); + if (ec) { + logCancelFailed(ec); + } } void logFailureInSetStreamNonBlocking(std::error_code ec); |