aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@gmail.com>2018-04-27 10:57:52 -0700
committerGravatar GitHub <noreply@github.com>2018-04-27 10:57:52 -0700
commitf44949cbb0be0f2dda67b3d516123804df1d01ef (patch)
tree75bfed031e4e194587e2b20902f3b7d7c4c4022e /src
parent23b53ee2283f3f14c9ad9692444f3cf08651a63f (diff)
parentf5f5ee31a25e37d6a19939f837f0089431f9951c (diff)
Merge pull request #14905 from ara-ayvazyan/enable_loopback_fastpath
Enable SIO_LOOPBACK_FAST_PATH on Windows
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/iomgr/tcp_windows.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc
index 04e6f11eee..5d316d477b 100644
--- a/src/core/lib/iomgr/tcp_windows.cc
+++ b/src/core/lib/iomgr/tcp_windows.cc
@@ -74,12 +74,28 @@ static grpc_error* set_dualstack(SOCKET sock) {
: GRPC_WSA_ERROR(WSAGetLastError(), "setsockopt(IPV6_V6ONLY)");
}
+static grpc_error* enable_loopback_fast_path(SOCKET sock) {
+ int status;
+ uint32_t param = 1;
+ DWORD ret;
+ status = WSAIoctl(sock, /*SIO_LOOPBACK_FAST_PATH==*/_WSAIOW(IOC_VENDOR, 16),
+ &param, sizeof(param), NULL, 0, &ret, 0, 0);
+ if (status == SOCKET_ERROR) {
+ status = WSAGetLastError();
+ }
+ return status == 0 || status == WSAEOPNOTSUPP
+ ? GRPC_ERROR_NONE
+ : GRPC_WSA_ERROR(status, "WSAIoctl(SIO_LOOPBACK_FAST_PATH)");
+}
+
grpc_error* grpc_tcp_prepare_socket(SOCKET sock) {
grpc_error* err;
err = set_non_block(sock);
if (err != GRPC_ERROR_NONE) return err;
err = set_dualstack(sock);
if (err != GRPC_ERROR_NONE) return err;
+ err = enable_loopback_fast_path(sock);
+ if (err != GRPC_ERROR_NONE) return err;
return GRPC_ERROR_NONE;
}