From 62b5c60ead59e29663a44a79148ee4ffdf2f6ec2 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 5 Aug 2015 08:41:57 +0200 Subject: [PATCH] syncCommand() comments improved. --- src/replication.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/replication.c b/src/replication.c index 72f29a07..12ff8ce9 100644 --- a/src/replication.c +++ b/src/replication.c @@ -544,6 +544,8 @@ void syncCommand(client *c) { /* Here we need to check if there is a background saving operation * in progress, or if it is required to start one */ + + /* CASE 1: BGSAVE is in progress and replication target is disk. */ if (server.rdb_child_pid != -1 && server.rdb_child_type == RDB_CHILD_TYPE_DISK) { @@ -572,6 +574,8 @@ void syncCommand(client *c) { c->replstate = SLAVE_STATE_WAIT_BGSAVE_START; serverLog(LL_NOTICE,"Waiting for next BGSAVE for SYNC"); } + + /* CASE 2: BGSAVE is in progress and replication target is socket. */ } else if (server.rdb_child_pid != -1 && server.rdb_child_type == RDB_CHILD_TYPE_SOCKET) { @@ -580,6 +584,8 @@ void syncCommand(client *c) { * in order to synchronize. */ c->replstate = SLAVE_STATE_WAIT_BGSAVE_START; serverLog(LL_NOTICE,"Waiting for next BGSAVE for SYNC"); + + /* CASE 3: There is no BGSAVE is progress. */ } else { if (server.repl_diskless_sync) { /* Diskless replication RDB child is created inside @@ -589,7 +595,8 @@ void syncCommand(client *c) { if (server.repl_diskless_sync_delay) serverLog(LL_NOTICE,"Delay next BGSAVE for SYNC"); } else { - /* Ok we don't have a BGSAVE in progress, let's start one. */ + /* Target is disk and we don't have a BGSAVE in progress, + * let's start one. */ if (startBgsaveForReplication() != C_OK) { serverLog(LL_NOTICE,"Replication failed, can't BGSAVE"); addReplyError(c,"Unable to perform background save");