summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-07-11 16:31:39 +0200
committerantirez <antirez@gmail.com>2013-07-11 17:09:44 +0200
commit076f6395b984d446e2d4b3b47e2f928371144a1a (patch)
tree47111785b3e28bbf1ef3a652eaabb1f3f25ab29a
parent4cfd70e90368c4dc3eff511acaca6db4b4f24077 (diff)
downloadredis-076f6395b984d446e2d4b3b47e2f928371144a1a.tar.gz
Sentinel: use comma as separator to publish hello messages.
We use comma to play well with IPv6 addresses, but the implementation is still able to parse the old messages separated by colons.
-rw-r--r--src/sentinel.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 594b7e498..62473b5c1 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -1741,9 +1741,13 @@ void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privd
{
int numtokens, port, removed, canfailover;
+ /* Separator changed from ":" to "," in recent versions in order to
+ * play well with IPv6 addresses. For now we make sure to parse both
+ * correctly detecting if there is "," inside the string. */
+ char *sep = strchr(r->element[2]->str,',') ? "," : ":";
char **token = sdssplitlen(r->element[2]->str,
r->element[2]->len,
- ":",1,&numtokens);
+ sep,1,&numtokens);
sentinelRedisInstance *sentinel;
if (numtokens == 4) {
@@ -1841,8 +1845,7 @@ void sentinelPingInstance(sentinelRedisInstance *ri) {
if (anetSockName(ri->cc->c.fd,ip,sizeof(ip),NULL) != -1) {
char myaddr[REDIS_IP_STR_LEN+128];
- // FIXME: IPv6 will break this due to nested : characters -geoffgarside
- snprintf(myaddr,sizeof(myaddr),"%s:%d:%s:%d",
+ snprintf(myaddr,sizeof(myaddr),"%s,%d,%s,%d",
ip, server.port, server.runid,
(ri->flags & SRI_CAN_FAILOVER) != 0);
retval = redisAsyncCommand(ri->cc,