Skip to content
Permalink
Browse files

Disable Nagle algorithm in Windows

  • Loading branch information...
abmahdy committed Apr 8, 2019
1 parent dc1089a commit 1dce1009e67ea4b5934a61b1bcf8a217bd12cc76
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/core/lib/iomgr/tcp_windows.cc
@@ -88,6 +88,19 @@ static grpc_error* enable_loopback_fast_path(SOCKET sock) {
: GRPC_WSA_ERROR(status, "WSAIoctl(SIO_LOOPBACK_FAST_PATH)");
}

static grpc_error* enable_socket_low_latency(SOCKET sock) {
int status;
BOOL param = TRUE;
status = ::setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
reinterpret_cast<char*>(&param), sizeof(param));
if (status == SOCKET_ERROR) {
status = WSAGetLastError();
}
return status == 0
? GRPC_ERROR_NONE
: GRPC_WSA_ERROR(status, "setsockopt(TCP_NODELAY)");
}

grpc_error* grpc_tcp_prepare_socket(SOCKET sock) {
grpc_error* err;
err = grpc_tcp_set_non_block(sock);
@@ -96,6 +109,8 @@ grpc_error* grpc_tcp_prepare_socket(SOCKET sock) {
if (err != GRPC_ERROR_NONE) return err;
err = enable_loopback_fast_path(sock);
if (err != GRPC_ERROR_NONE) return err;
err = enable_socket_low_latency(sock);
if (err != GRPC_ERROR_NONE) return err;
return GRPC_ERROR_NONE;
}

0 comments on commit 1dce100

Please sign in to comment.
You can’t perform that action at this time.