Use inet_ntop(3) in nodeIp2String & clusterCommand
Replace inet_ntoa(3) calls with the more future proof inet_ntop(3) function which is capable of handling additional address families.
This commit is contained in:
parent
8b2e90acec
commit
c87105431c
@ -758,7 +758,7 @@ void nodeIp2String(char *buf, clusterLink *link) {
|
|||||||
|
|
||||||
if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1)
|
if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1)
|
||||||
redisPanic("getpeername() failed.");
|
redisPanic("getpeername() failed.");
|
||||||
strncpy(buf,inet_ntoa(sa.sin_addr),sizeof(link->node->ip));
|
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),buf,sizeof(link->node->ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2084,7 +2084,7 @@ void clusterCommand(redisClient *c) {
|
|||||||
/* Finally add the node to the cluster with a random name, this
|
/* Finally add the node to the cluster with a random name, this
|
||||||
* will get fixed in the first handshake (ping/pong). */
|
* will get fixed in the first handshake (ping/pong). */
|
||||||
n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET);
|
n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET);
|
||||||
strncpy(n->ip,inet_ntoa(sa.sin_addr),sizeof(n->ip));
|
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),n->ip,sizeof(n->ip));
|
||||||
n->port = port;
|
n->port = port;
|
||||||
clusterAddNode(n);
|
clusterAddNode(n);
|
||||||
addReply(c,shared.ok);
|
addReply(c,shared.ok);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user