summaryrefslogtreecommitdiff
path: root/src/third_party
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/third_party
parent1ef8e418f15120c90699cfc5c6046f50bba7926a (diff)
downloadmongo-975d539ae068bd27ebb478b6f3673b89d2ad6beb.tar.gz
SERVER-33299 Add support for timeouts to TransportLayerASIO Sessions
Diffstat (limited to 'src/third_party')
-rw-r--r--src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp57
-rw-r--r--src/third_party/asio-master/patches/0003-MONGO-HACK-allow-blocking-sockets-to-timeout.patch78
2 files changed, 91 insertions, 44 deletions
diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp
index b3b1a0cf811..2f89889fac8 100644
--- a/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp
+++ b/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp
@@ -803,33 +803,19 @@ size_t sync_recv(socket_type s, state_type state, buf* bufs,
return 0;
}
- // Read some data.
- for (;;)
- {
- // Try to complete the operation without blocking.
- signed_size_type bytes = socket_ops::recv(s, bufs, count, flags, ec);
-
- // Check if operation succeeded.
- if (bytes > 0)
- return bytes;
+ signed_size_type bytes = socket_ops::recv(s, bufs, count, flags, ec);
- // Check for EOF.
- if ((state & stream_oriented) && bytes == 0)
- {
- ec = asio::error::eof;
- return 0;
- }
+ // Check if operation succeeded.
+ if (bytes > 0)
+ return bytes;
- // Operation failed.
- if ((state & user_set_non_blocking)
- || (ec != asio::error::would_block
- && ec != asio::error::try_again))
- return 0;
-
- // Wait for socket to become ready.
- if (socket_ops::poll_read(s, 0, -1, ec) < 0)
- return 0;
+ // Check for EOF.
+ if ((state & stream_oriented) && bytes == 0)
+ {
+ ec = asio::error::eof;
}
+
+ return 0;
}
#if defined(ASIO_HAS_IOCP)
@@ -1203,26 +1189,9 @@ size_t sync_send(socket_type s, state_type state, const buf* bufs,
return 0;
}
- // Read some data.
- for (;;)
- {
- // Try to complete the operation without blocking.
- signed_size_type bytes = socket_ops::send(s, bufs, count, flags, ec);
-
- // Check if operation succeeded.
- if (bytes >= 0)
- return bytes;
-
- // Operation failed.
- if ((state & user_set_non_blocking)
- || (ec != asio::error::would_block
- && ec != asio::error::try_again))
- return 0;
-
- // Wait for socket to become ready.
- if (socket_ops::poll_write(s, 0, -1, ec) < 0)
- return 0;
- }
+ // Write some data
+ signed_size_type bytes = socket_ops::send(s, bufs, count, flags, ec);
+ return bytes;
}
#if defined(ASIO_HAS_IOCP)
diff --git a/src/third_party/asio-master/patches/0003-MONGO-HACK-allow-blocking-sockets-to-timeout.patch b/src/third_party/asio-master/patches/0003-MONGO-HACK-allow-blocking-sockets-to-timeout.patch
new file mode 100644
index 00000000000..ba9186dd010
--- /dev/null
+++ b/src/third_party/asio-master/patches/0003-MONGO-HACK-allow-blocking-sockets-to-timeout.patch
@@ -0,0 +1,78 @@
+diff --git a/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp b/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp
+index b3b1a0cf81..2f89889fac 100644
+--- a/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp
++++ b/src/third_party/asio-master/asio/include/asio/detail/impl/socket_ops.ipp
+@@ -803,33 +803,19 @@ size_t sync_recv(socket_type s, state_type state, buf* bufs,
+ return 0;
+ }
+
+- // Read some data.
+- for (;;)
+- {
+- // Try to complete the operation without blocking.
+- signed_size_type bytes = socket_ops::recv(s, bufs, count, flags, ec);
+-
+- // Check if operation succeeded.
+- if (bytes > 0)
+- return bytes;
++ signed_size_type bytes = socket_ops::recv(s, bufs, count, flags, ec);
+
+- // Check for EOF.
+- if ((state & stream_oriented) && bytes == 0)
+- {
+- ec = asio::error::eof;
+- return 0;
+- }
++ // Check if operation succeeded.
++ if (bytes > 0)
++ return bytes;
+
+- // Operation failed.
+- if ((state & user_set_non_blocking)
+- || (ec != asio::error::would_block
+- && ec != asio::error::try_again))
+- return 0;
+-
+- // Wait for socket to become ready.
+- if (socket_ops::poll_read(s, 0, -1, ec) < 0)
+- return 0;
++ // Check for EOF.
++ if ((state & stream_oriented) && bytes == 0)
++ {
++ ec = asio::error::eof;
+ }
++
++ return 0;
+ }
+
+ #if defined(ASIO_HAS_IOCP)
+@@ -1203,26 +1189,9 @@ size_t sync_send(socket_type s, state_type state, const buf* bufs,
+ return 0;
+ }
+
+- // Read some data.
+- for (;;)
+- {
+- // Try to complete the operation without blocking.
+- signed_size_type bytes = socket_ops::send(s, bufs, count, flags, ec);
+-
+- // Check if operation succeeded.
+- if (bytes >= 0)
+- return bytes;
+-
+- // Operation failed.
+- if ((state & user_set_non_blocking)
+- || (ec != asio::error::would_block
+- && ec != asio::error::try_again))
+- return 0;
+-
+- // Wait for socket to become ready.
+- if (socket_ops::poll_write(s, 0, -1, ec) < 0)
+- return 0;
+- }
++ // Write some data
++ signed_size_type bytes = socket_ops::send(s, bufs, count, flags, ec);
++ return bytes;
+ }
+
+ #if defined(ASIO_HAS_IOCP)