diff --git a/src/networking.c b/src/networking.c index 1b1c9180..500df0d8 100644 --- a/src/networking.c +++ b/src/networking.c @@ -48,6 +48,7 @@ redisClient *createClient(int fd) { c->lastinteraction = time(NULL); c->authenticated = 0; c->replstate = REDIS_REPL_NONE; + c->slave_listening_port = 0; c->reply = listCreate(); c->reply_bytes = 0; listSetFreeMethod(c->reply,decrRefCount); diff --git a/src/redis.c b/src/redis.c index b13db8b8..3267744d 100644 --- a/src/redis.c +++ b/src/redis.c @@ -173,6 +173,7 @@ struct redisCommand readonlyCommandTable[] = { {"exec",execCommand,1,REDIS_CMD_DENYOOM,execBlockClientOnSwappedKeys,0,0,0}, {"discard",discardCommand,1,0,NULL,0,0,0}, {"sync",syncCommand,1,0,NULL,0,0,0}, + {"replconf",replconfCommand,-1,0,NULL,0,0,0}, {"flushdb",flushdbCommand,1,0,NULL,0,0,0}, {"flushall",flushallCommand,1,0,NULL,0,0,0}, {"sort",sortCommand,-2,REDIS_CMD_DENYOOM,NULL,1,1,1}, @@ -1401,7 +1402,7 @@ sds genRedisInfoString(void) { } if (state == NULL) continue; info = sdscatprintf(info,"slave%d:%s,%d,%s\r\n", - slaveid,ip,port,state); + slaveid,ip,slave->slave_listening_port,state); slaveid++; } } diff --git a/src/redis.h b/src/redis.h index 86e78cac..34b58d46 100644 --- a/src/redis.h +++ b/src/redis.h @@ -351,6 +351,7 @@ typedef struct redisClient { int repldbfd; /* replication DB file descriptor */ long repldboff; /* replication DB file offset */ off_t repldbsize; /* replication DB file size */ + int slave_listening_port; /* As configured with: SLAVECONF listening-port */ multiState mstate; /* MULTI/EXEC state */ blockingState bpop; /* blocking state */ list *io_keys; /* Keys this client is waiting to be loaded from the @@ -1071,6 +1072,7 @@ void watchCommand(redisClient *c); void unwatchCommand(redisClient *c); void objectCommand(redisClient *c); void clientCommand(redisClient *c); +void replconfCommand(redisClient *c); #if defined(__GNUC__) void *calloc(size_t count, size_t size) __attribute__ ((deprecated)); diff --git a/src/replication.c b/src/replication.c index 80d2d26b..884b0c49 100644 --- a/src/replication.c +++ b/src/replication.c @@ -139,6 +139,46 @@ void syncCommand(redisClient *c) { return; } +/* REPLCONF