diff options
author | Gaurav <gaurav@gluster.com> | 2011-07-26 11:34:10 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-27 01:40:25 -0700 |
commit | 48665f87f55d07eb790c882e5b10217416140319 (patch) | |
tree | db0dcf669c657158c1d37b90c6201e549da2dc10 /rpc/rpc-transport | |
parent | b922437795a68b32cd6fb337dfd66a4ead13b4ee (diff) |
Glusterd: Remove dependency on AI_ADDRCONFIG for AF_UNSPEC
Change-Id: I0a22b2cc5a0ea1a57633fddabad54aca7b3d4e86
BUG: 2456
Reviewed-on: http://review.gluster.com/102
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Csaba Henk <csaba@gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'rpc/rpc-transport')
-rw-r--r-- | rpc/rpc-transport/socket/src/name.c | 19 | ||||
-rw-r--r-- | rpc/rpc-transport/socket/src/socket.c | 2 |
2 files changed, 16 insertions, 5 deletions
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c index ca0184576c9..582a781a43f 100644 --- a/rpc/rpc-transport/socket/src/name.c +++ b/rpc/rpc-transport/socket/src/name.c @@ -356,7 +356,7 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, struct sockaddr *addr, socklen_t *addr_len) { - struct addrinfo hints, *res = 0; + struct addrinfo hints, *res = 0, *rp = NULL; data_t *listen_port_data = NULL, *listen_host_data = NULL; uint16_t listen_port = -1; char service[NI_MAXSERV], *listen_host = NULL; @@ -402,7 +402,7 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, memset (&hints, 0, sizeof (hints)); hints.ai_family = addr->sa_family; hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE; + hints.ai_flags = AI_PASSIVE; ret = getaddrinfo(listen_host, service, &hints, &res); if (ret != 0) { @@ -412,9 +412,20 @@ af_inet_server_get_local_sockaddr (rpc_transport_t *this, ret = -1; goto out; } + /* IPV6 server can handle both ipv4 and ipv6 clients */ + for (rp = res; rp != NULL; rp = rp->ai_next) { + if (rp->ai_addr == NULL) + continue; + if (rp->ai_family == AF_INET6) { + memcpy (addr, rp->ai_addr, rp->ai_addrlen); + *addr_len = rp->ai_addrlen; + } + } - memcpy (addr, res->ai_addr, res->ai_addrlen); - *addr_len = res->ai_addrlen; + if (!(*addr_len)) { + memcpy (addr, res->ai_addr, res->ai_addrlen); + *addr_len = res->ai_addrlen; + } freeaddrinfo (res); diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 9937dc4a6e6..23889b52077 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -2113,7 +2113,7 @@ socket_listen (rpc_transport_t *this) int ret = -1; int sock = -1; struct sockaddr_storage sockaddr; - socklen_t sockaddr_len; + socklen_t sockaddr_len = 0; peer_info_t *myinfo = NULL; glusterfs_ctx_t *ctx = NULL; sa_family_t sa_family = {0, }; |