diff --git a/src/networking.c b/src/networking.c index 071f5aaf..ceef89f3 100644 --- a/src/networking.c +++ b/src/networking.c @@ -127,7 +127,8 @@ redisClient *createClient(int fd) { * data should be appended to the output buffers. */ int prepareClientToWrite(redisClient *c) { if (c->flags & REDIS_LUA_CLIENT) return REDIS_OK; - if (c->flags & REDIS_MASTER) return REDIS_ERR; + if ((c->flags & REDIS_MASTER) && + !(c->flags & REDIS_MASTER_FORCE_REPLY)) return REDIS_ERR; if (c->fd <= 0) return REDIS_ERR; /* Fake client */ if (c->bufpos == 0 && listLength(c->reply) == 0 && (c->replstate == REDIS_REPL_NONE || diff --git a/src/redis.c b/src/redis.c index f86dafa5..04e979c0 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1868,6 +1868,15 @@ int processCommand(redisClient *c) { call(c,REDIS_CALL_FULL); if (listLength(server.ready_keys)) handleClientsBlockedOnLists(); + /* Acknowledge the master about the execution of this command. */ + if (c->flags & REDIS_MASTER) { + c->flags |= REDIS_MASTER_FORCE_REPLY; + addReplyMultiBulkLen(c,3); + addReplyBulkCString(c,"REPLCONF"); + addReplyBulkCString(c,"ACK"); + addReplyBulkLongLong(c,c->reploff); + c->flags &= ~REDIS_MASTER_FORCE_REPLY; + } } return REDIS_OK; } @@ -2337,8 +2346,9 @@ sds genRedisInfoString(char *section) { break; } if (state == NULL) continue; - info = sdscatprintf(info,"slave%d:%s,%d,%s\r\n", - slaveid,ip,slave->slave_listening_port,state); + info = sdscatprintf(info,"slave%d:%s,%d,%s,%lld\r\n", + slaveid,ip,slave->slave_listening_port,state, + slave->repl_ack_off); slaveid++; } } diff --git a/src/redis.h b/src/redis.h index f9a692ea..e4045c11 100644 --- a/src/redis.h +++ b/src/redis.h @@ -213,6 +213,7 @@ #define REDIS_CLOSE_ASAP (1<<10)/* Close this client ASAP */ #define REDIS_UNIX_SOCKET (1<<11) /* Client connected via Unix domain socket */ #define REDIS_DIRTY_EXEC (1<<12) /* EXEC will fail for errors while queueing */ +#define REDIS_MASTER_FORCE_REPLY (1<<13) /* Queue replies even if is master */ /* Client request types */ #define REDIS_REQ_INLINE 1