Merge pull request #14905 from ara-ayvazyan/enable_loopback_fastpath

Enable SIO_LOOPBACK_FAST_PATH on Windows
pull/12775/head
Noah Eisen 7 years ago committed by GitHub
commit f44949cbb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      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;
}

Loading…
Cancel
Save