From efd87031d06aadada48a6f04fbb031d2155bb2c4 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 27 May 2013 10:41:53 +0200 Subject: [PATCH] Don't ACK the master after every command. Sending an ACK is now moved into the replicationSendAck() function. --- src/redis.c | 9 --------- src/replication.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/redis.c b/src/redis.c index 04e979c0..d6883750 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1868,15 +1868,6 @@ 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; } diff --git a/src/replication.c b/src/replication.c index 70ed8605..a326ee8a 100644 --- a/src/replication.c +++ b/src/replication.c @@ -1302,6 +1302,22 @@ void slaveofCommand(redisClient *c) { addReply(c,shared.ok); } +/* Send a REPLCONF ACK command to the master to inform it about the current + * processed offset. If we are not connected with a master, the command has + * no effects. */ +void replicationSendAck(void) { + redisClient *c = server.master; + + if (c != NULL) { + 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; + } +} + /* ---------------------- MASTER CACHING FOR PSYNC -------------------------- */ /* In order to implement partial synchronization we need to be able to cache @@ -1390,6 +1406,7 @@ void replicationResurrectCachedMaster(int newfd) { /* --------------------------- REPLICATION CRON ---------------------------- */ +/* Replication cron funciton, called 1 time per second. */ void replicationCron(void) { /* Non blocking connection timeout? */ if (server.masterhost &&