From d2040ab9b13bc4edd07825e2ecee55b3679e0651 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Wed, 26 Feb 2014 18:02:55 -0500 Subject: [PATCH] Remove some redundant code Function nodeIp2String in cluster.c is exactly anetPeerToString with a pre-extracted fd. --- src/cluster.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index be7e5916..e6da3a66 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1021,22 +1021,9 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { /* IP -> string conversion. 'buf' is supposed to at least be 46 bytes. */ void nodeIp2String(char *buf, clusterLink *link) { - struct sockaddr_storage sa; - socklen_t salen = sizeof(sa); - - if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1) - redisPanic("getpeername() failed."); - - if (sa.ss_family == AF_INET) { - struct sockaddr_in *s = (struct sockaddr_in *)&sa; - inet_ntop(AF_INET,(void*)&(s->sin_addr),buf,REDIS_CLUSTER_IPLEN); - } else { - struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa; - inet_ntop(AF_INET6,(void*)&(s->sin6_addr),buf,REDIS_CLUSTER_IPLEN); - } + anetPeerToString(link->fd, buf, REDIS_CLUSTER_IPLEN, NULL); } - /* Update the node address to the IP address that can be extracted * from link->fd, and at the specified port. * Also disconnect the node link so that we'll connect again to the new