mirror of
https://github.com/fluencelabs/redis
synced 2025-06-12 08:41:21 +00:00
Add macro to define clusterNode.ip buffer size.
Add REDIS_CLUSTER_IPLEN macro to define the size of the clusterNode ip character array. Additionally use this macro in inet_ntop(3) calls where the size of the array was being defined manually. The REDIS_CLUSTER_IPLEN is defined as INET_ADDRSTRLEN which defines the correct size of a buffer to store an IPv4 address in. The INET_ADDRSTRLEN macro itself is defined in the <netinet/in.h> header file and should be portable across the majority of systems.
This commit is contained in:
@ -758,7 +758,7 @@ void nodeIp2String(char *buf, clusterLink *link) {
|
||||
|
||||
if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1)
|
||||
redisPanic("getpeername() failed.");
|
||||
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),buf,16);
|
||||
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),buf,REDIS_CLUSTER_IPLEN);
|
||||
}
|
||||
|
||||
|
||||
@ -2084,7 +2084,7 @@ void clusterCommand(redisClient *c) {
|
||||
/* Finally add the node to the cluster with a random name, this
|
||||
* will get fixed in the first handshake (ping/pong). */
|
||||
n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET);
|
||||
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),n->ip,16);
|
||||
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),n->ip,REDIS_CLUSTER_IPLEN);
|
||||
n->port = port;
|
||||
clusterAddNode(n);
|
||||
addReply(c,shared.ok);
|
||||
|
Reference in New Issue
Block a user