diff options
author | Matt Stancliff <matt@genges.com> | 2014-02-26 18:02:55 -0500 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-03-11 11:09:37 +0100 |
commit | 7c8964a8cf42d33f9e0ca65c9990978b16baa386 (patch) | |
tree | 80d111c7e7ed033e5b82458bd324fc76341cc18d | |
parent | 7c359449d52b2a79770348f1ebb1cf57e6d317e2 (diff) | |
download | redis-7c8964a8cf42d33f9e0ca65c9990978b16baa386.tar.gz |
Remove some redundant code
Function nodeIp2String in cluster.c is exactly
anetPeerToString with a pre-extracted fd.
-rw-r--r-- | src/cluster.c | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/cluster.c b/src/cluster.c index 6f05da85f..cc2ceb24c 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1034,22 +1034,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 |