]> git.saurik.com Git - redis.git/commitdiff
More robust handling of AOF rewrite child.
authorantirez <antirez@gmail.com>
Thu, 1 Nov 2012 21:39:39 +0000 (22:39 +0100)
committerantirez <antirez@gmail.com>
Thu, 1 Nov 2012 21:41:57 +0000 (22:41 +0100)
After the wait3() syscall we used to do something like that:

    if (pid == server.rdb_child_pid) {
        backgroundSaveDoneHandler(exitcode,bysignal);
    } else {
        ....
    }

So the AOF rewrite was handled in the else branch without actually
checking if the pid really matches. This commit makes the check explicit
and logs at WARNING level if the pid returned by wait3() does not match
neither the RDB or AOF rewrite child.

src/redis.c

index 87f5e812f80ae001b9059f582e02c40bce69a1c9..b42fac3541376021cb1824feaa28534ca521ec78 100644 (file)
@@ -902,8 +902,12 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
 
             if (pid == server.rdb_child_pid) {
                 backgroundSaveDoneHandler(exitcode,bysignal);
-            } else {
+            } else if (pid == server.aof_child_pid) {
                 backgroundRewriteDoneHandler(exitcode,bysignal);
+            } else {
+                redisLog(REDIS_WARNING,
+                    "Warning, detected child with unmatched pid: %ld",
+                    (long)pid);
             }
             updateDictResizePolicy();
         }