diff --git a/src/rdb.c b/src/rdb.c index ab24c642..0fcf426f 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1066,13 +1066,17 @@ void rdbLoadProgressCallback(rio *r, const void *buf, size_t len) { (r->processed_bytes + len)/server.loading_process_events_interval_bytes > r->processed_bytes/server.loading_process_events_interval_bytes) { if (server.masterhost && server.repl_state == REDIS_REPL_TRANSFER) { + static time_t newline_sent; /* Avoid the master to detect the slave is timing out while * loading the RDB file in initial synchronization. We send * a single newline character that is valid protocol but is * guaranteed to either be sent entierly or not, since the byte * is indivisible. */ - if (write(server.repl_transfer_s,"\n",1) == -1) { - /* Pinging back in this stage is best-effort. */ + if (time(NULL) != newline_sent) { + newline_sent = time(NULL); + if (write(server.repl_transfer_s,"\n",1) == -1) { + /* Pinging back in this stage is best-effort. */ + } } } loadingProgress(r->processed_bytes);