summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-07-04 15:35:01 +0200
committerantirez <antirez@gmail.com>2014-07-04 15:35:01 +0200
commit75ef41058dc20ca913f25f3edf513ea41cb72ed0 (patch)
tree3a2a19e41cc2ac0106de044a8f91445bd9fffabb
parent2fa9fb647f24362a33c95e057826a70e7c433d82 (diff)
downloadredis-75ef41058dc20ca913f25f3edf513ea41cb72ed0.tar.gz
Use a timeout when reading parent ack from AOF child.
-rw-r--r--src/aof.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/aof.c b/src/aof.c
index 868a3297b..ac5fb8aa2 100644
--- a/src/aof.c
+++ b/src/aof.c
@@ -1040,9 +1040,15 @@ int rewriteAppendOnlyFile(char *filename) {
}
/* Ask the master to stop sending diffs. */
- write(server.aof_pipe_write_ack_to_parent,"!",1);
- if (read(server.aof_pipe_read_ack_from_parent,&byte,1) != 1 ||
+ if (write(server.aof_pipe_write_ack_to_parent,"!",1) != 1) goto werr;
+ if (anetNonBlock(NULL,server.aof_pipe_read_ack_from_parent) != ANET_OK)
+ goto werr;
+ /* We read the ACK from the server using a 10 seconds timeout. Normally
+ * it should reply ASAP, but just in case we lose its reply, we are sure
+ * the child will eventually get terminated. */
+ if (syncRead(server.aof_pipe_read_ack_from_parent,&byte,1,5000) != 1 ||
byte != '!') goto werr;
+ redisLog(REDIS_NOTICE,"Parent agreed to stop sending diffs. Finalizing AOF...");
/* Read the final diff if any. */
aofReadDiffFromParent();