aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Sree Kuchibhotla <sreecha@users.noreply.github.com>2018-03-20 10:04:00 -0700
committerGravatar GitHub <noreply@github.com>2018-03-20 10:04:00 -0700
commit3136dd367df4f41d0a6f129c79e9f9a0344ce674 (patch)
tree6e724f0b710a7b6709ba2be357b6017d50fc51cc /src
parent5062ce8a5ce85655e702dd1afed4cbba7f3aa004 (diff)
parent1c6f655925e6e5c3eb8b05779e1ecdbfa8a141ff (diff)
Merge pull request #14748 from sreecha/fix_reuseport
Enable SO_REUSEPORT in ipv6-only environments as well
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/iomgr/tcp_server_posix.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
index ce70116e1d..4e1d90e86a 100644
--- a/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -61,6 +61,11 @@ static bool has_so_reuseport = false;
static void init(void) {
#ifndef GPR_MANYLINUX1
int s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s < 0) {
+ /* This might be an ipv6-only environment in which case 'socket(AF_INET,..)'
+ call would fail. Try creating IPv6 socket in that case */
+ s = socket(AF_INET6, SOCK_STREAM, 0);
+ }
if (s >= 0) {
has_so_reuseport = GRPC_LOG_IF_ERROR("check for SO_REUSEPORT",
grpc_set_socket_reuse_port(s, 1));