diff --git a/src/cluster.c b/src/cluster.c index 4e42737f..ec6901e8 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1547,18 +1547,20 @@ int clusterProcessPacket(clusterLink *link) { * later if we changed address, and those nodes will use our * official address to connect to us. So by obtaining this address * from the socket is a simple way to discover / update our own - * address in the cluster without it being hardcoded in the config. */ - if (type == CLUSTERMSG_TYPE_MEET) { + * address in the cluster without it being hardcoded in the config. + * + * However if we don't have an address at all, we update the address + * even with a normal PING packet. If it's wrong it will be fixed + * by MEET later. */ + if (type == CLUSTERMSG_TYPE_MEET || myself->ip[0] == '\0') { char ip[REDIS_IP_STR_LEN]; if (anetSockName(link->fd,ip,sizeof(ip),NULL) != -1 && strcmp(ip,myself->ip)) { memcpy(myself->ip,ip,REDIS_IP_STR_LEN); - - anetFormatAddr(ip, sizeof(ip), myself->ip, -1); redisLog(REDIS_WARNING,"IP address for this node updated to %s", - ip); + myself->ip); clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG); } }