summaryrefslogtreecommitdiff
path: root/src/mongo/transport/asio_utils.h
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2018-02-14 14:47:52 -0500
committerJonathan Reams <jbreams@mongodb.com>2018-03-02 11:04:56 -0500
commit975d539ae068bd27ebb478b6f3673b89d2ad6beb (patch)
treebe4081de61244b451b2fb44ae37f58b2098e321a /src/mongo/transport/asio_utils.h
parent1ef8e418f15120c90699cfc5c6046f50bba7926a (diff)
downloadmongo-975d539ae068bd27ebb478b6f3673b89d2ad6beb.tar.gz
SERVER-33299 Add support for timeouts to TransportLayerASIO Sessions
Diffstat (limited to 'src/mongo/transport/asio_utils.h')
-rw-r--r--src/mongo/transport/asio_utils.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/transport/asio_utils.h b/src/mongo/transport/asio_utils.h
index 141ec4f78ea..89e7821f5b8 100644
--- a/src/mongo/transport/asio_utils.h
+++ b/src/mongo/transport/asio_utils.h
@@ -54,6 +54,14 @@ inline Status errorCodeToStatus(const std::error_code& ec) {
if (!ec)
return Status::OK();
+#ifdef _WIN32
+ if (ec == asio::error::timed_out) {
+#else
+ if (ec == asio::error::try_again || ec == asio::error::would_block) {
+#endif
+ return {ErrorCodes::NetworkTimeout, "Socket operation timed out"};
+ }
+
// If the ec.category() is a mongoErrorCategory() then this error was propogated from
// mongodb code and we should just pass the error cdoe along as-is.
ErrorCodes::Error errorCode = (ec.category() == mongoErrorCategory())