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();
This commit is contained in:
antirez 2016-12-16 17:48:33 +01:00
parent ca4ca5073e
commit 8e390a62ad

View File

@ -1241,14 +1241,16 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
if (eof_reached) { if (eof_reached) {
int aof_is_enabled = server.aof_state != AOF_OFF; int aof_is_enabled = server.aof_state != AOF_OFF;
if (rename(server.repl_transfer_tmpfile,server.rdb_filename) == -1) { 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)); serverLog(LL_WARNING,"Failed trying to rename the temp DB into dump.rdb in MASTER <-> SLAVE synchronization: %s", strerror(errno));
cancelReplicationHandshake(); cancelReplicationHandshake();
return; return;
} }
serverLog(LL_NOTICE, "MASTER <-> SLAVE sync: Flushing old data"); 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 */ /* We need to stop any AOFRW fork before flusing and parsing
stopAppendOnly(); * RDB, otherwise we'll create a copy-on-write disaster. */
if(aof_is_enabled) stopAppendOnly();
signalFlushedDb(-1); signalFlushedDb(-1);
emptyDb( emptyDb(
-1, -1,
@ -1264,8 +1266,9 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
if (rdbLoad(server.rdb_filename,&rsi) != C_OK) { if (rdbLoad(server.rdb_filename,&rsi) != C_OK) {
serverLog(LL_WARNING,"Failed trying to load the MASTER synchronization DB from disk"); serverLog(LL_WARNING,"Failed trying to load the MASTER synchronization DB from disk");
cancelReplicationHandshake(); cancelReplicationHandshake();
if (aof_is_enabled) /* re-enable so that on the next attempt, we can detect that AOF was enabled */ /* Re-enable the AOF if we disabled it earlier, in order to restore
restartAOF(); * the original configuration. */
if (aof_is_enabled) restartAOF();
return; return;
} }
/* Final setup of the connected slave <- master link */ /* 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 /* Restart the AOF subsystem now that we finished the sync. This
* will trigger an AOF rewrite, and when done will start appending * will trigger an AOF rewrite, and when done will start appending
* to the new file. */ * to the new file. */
if (aof_is_enabled) if (aof_is_enabled) restartAOF();
restartAOF();
} }
return; return;
error: error: