summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-12-16 17:48:33 +0100
committerantirez <antirez@gmail.com>2016-12-16 17:48:38 +0100
commit8e390a62ad3b06e0f11813d0c832721f0b676d63 (patch)
tree5c3aa38d363c3cedadf2d8a138f1378848f8a10c
parentca4ca5073e394cca3f5c8f8c508803a6d9b2c606 (diff)
downloadredis-8e390a62ad3b06e0f11813d0c832721f0b676d63.tar.gz
Hopefully improve code comments for issue #3616.
This commit also contains other changes in order to conform the code to the Redis core style, specifically 80 chars max per line, smart conditionals in the same line: if (that) do_this();
-rw-r--r--src/replication.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/replication.c b/src/replication.c
index f26c142a9..df2e23f3a 100644
--- a/src/replication.c
+++ b/src/replication.c
@@ -1241,14 +1241,16 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
if (eof_reached) {
int aof_is_enabled = server.aof_state != AOF_OFF;
+
if (rename(server.repl_transfer_tmpfile,server.rdb_filename) == -1) {
serverLog(LL_WARNING,"Failed trying to rename the temp DB into dump.rdb in MASTER <-> SLAVE synchronization: %s", strerror(errno));
cancelReplicationHandshake();
return;
}
serverLog(LL_NOTICE, "MASTER <-> SLAVE sync: Flushing old data");
- if(aof_is_enabled) /* we need to stop any AOFRW fork before flusing and parsing RDB, otherwise we'll create a CoW disaster */
- stopAppendOnly();
+ /* We need to stop any AOFRW fork before flusing and parsing
+ * RDB, otherwise we'll create a copy-on-write disaster. */
+ if(aof_is_enabled) stopAppendOnly();
signalFlushedDb(-1);
emptyDb(
-1,
@@ -1264,8 +1266,9 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
if (rdbLoad(server.rdb_filename,&rsi) != C_OK) {
serverLog(LL_WARNING,"Failed trying to load the MASTER synchronization DB from disk");
cancelReplicationHandshake();
- if (aof_is_enabled) /* re-enable so that on the next attempt, we can detect that AOF was enabled */
- restartAOF();
+ /* Re-enable the AOF if we disabled it earlier, in order to restore
+ * the original configuration. */
+ if (aof_is_enabled) restartAOF();
return;
}
/* Final setup of the connected slave <- master link */
@@ -1289,10 +1292,8 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
/* Restart the AOF subsystem now that we finished the sync. This
* will trigger an AOF rewrite, and when done will start appending
* to the new file. */
- if (aof_is_enabled)
- restartAOF();
+ if (aof_is_enabled) restartAOF();
}
-
return;
error: