Skip to content

Commit

Permalink
Merge pull request #14748 from sreecha/fix_reuseport
Browse files Browse the repository at this point in the history
Enable SO_REUSEPORT in ipv6-only environments as well
  • Loading branch information
sreecha committed Mar 20, 2018
2 parents 5062ce8 + 1c6f655 commit 3136dd3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/lib/iomgr/tcp_server_posix.cc
Expand Up @@ -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));
Expand Down

0 comments on commit 3136dd3

Please sign in to comment.