From 30c42f12b098a5e44fe7f517ba0a47e5c4b5e588 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Fri, 4 Jul 2014 15:37:40 +0200
Subject: [PATCH] Handle write failure in AOF parent -> child ACK.

---
 src/aof.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/aof.c b/src/aof.c
index ac5fb8aa..721e5df7 100644
--- a/src/aof.c
+++ b/src/aof.c
@@ -1096,7 +1096,14 @@ void aofChildPipeReadable(aeEventLoop *el, int fd, void *privdata, int mask) {
     if (read(fd,&byte,1) == 1 && byte == '!') {
         redisLog(REDIS_NOTICE,"AOF rewrite child asks to stop sending diffs.");
         server.aof_stop_sending_diff = 1;
-        write(server.aof_pipe_write_ack_to_child,"!",1);
+        if (write(server.aof_pipe_write_ack_to_child,"!",1) != 1) {
+            /* If we can't send the ack, inform the user, but don't try again
+             * since in the other side the children will use a timeout if the
+             * kernel can't buffer our write, or, the children was
+             * terminated. */
+            redisLog(REDIS_WARNING,"Can't send ACK to AOF child: %s",
+                strerror(errno));
+        }
     }
     /* Remove the handler since this can be called only one time during a
      * rewrite. */