提交 0292c5f7 编写于 作者: A antirez

Replication: send REPLCONF ACK to master.

上级 6b4635f4
......@@ -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 ||
......
......@@ -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++;
}
}
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册