From 4f9bdf4e06465205dc13715b07b428a2cc4a87c2 Mon Sep 17 00:00:00 2001 From: Guantao Liu Date: Fri, 9 Nov 2018 16:22:21 -0800 Subject: [PATCH] Enable SO_REUSEADDR in client sockets --- src/core/lib/iomgr/tcp_client_posix.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index 8553ed0db4e..0bff74e88b3 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -76,6 +76,8 @@ static grpc_error* prepare_socket(const grpc_resolved_address* addr, int fd, if (!grpc_is_unix_socket(addr)) { err = grpc_set_socket_low_latency(fd, 1); if (err != GRPC_ERROR_NONE) goto error; + err = grpc_set_socket_reuse_addr(fd, 1); + if (err != GRPC_ERROR_NONE) goto error; err = grpc_set_socket_tcp_user_timeout(fd, channel_args, true /* is_client */); if (err != GRPC_ERROR_NONE) goto error;