summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-05-25 00:54:00 +0200
committerantirez <antirez@gmail.com>2013-05-25 01:15:35 +0200
commit3ce1089d6af6b343a1b55d2d1337fc5679279e9c (patch)
tree2b83d8898fe856d55a0dda59f21b1665a5252055
parentcf1e5ce6a30c7a9796e19966afcc3975c992d064 (diff)
downloadredis-3ce1089d6af6b343a1b55d2d1337fc5679279e9c.tar.gz
Replication: send REPLCONF ACK to master.
-rw-r--r--src/networking.c3
-rw-r--r--src/redis.c14
-rw-r--r--src/redis.h1
3 files changed, 15 insertions, 3 deletions
diff --git a/src/networking.c b/src/networking.c
index 071f5aafd..ceef89f35 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 f86dafa53..04e979c03 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 f9a692ea6..e4045c11f 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