Permalink
Browse files

Fix children reduction issue with restartChildren option.

Since the "exit" listeners are not guarantee to be executed in reverse
order, it can result in recreating the wrong children at a different
index, resulting in less children.

Example:

    children = [a, b]
    exit 0 -> children.splice(0, 1) -> [b] -> createChild(1) -> [b, a']
    exit 1 -> children.splice(1, 1) -> [b] -> createChild(1) -> [b, b']

	children = [a, b]
	exit 1 -> children.splice(1, 1) -> [a] -> createChild(1) -> [a, b']
	exit 0 -> children.splice(0, 1) -> [b'] -> createChild(1) -> [b', a']
  • Loading branch information...
4d47 committed Aug 31, 2011
1 parent 9580da1 commit 19b22a02033faa4432ae5fb3769a8422ec279bd2
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/multi-node.js
View
@@ -81,10 +81,10 @@ exports.listen = function(options, server){
// cleanup connections
[].concat(childConnection, siblingConnection, masterChildConnection).forEach(netBinding.close);
// remove the dead one
- children.splice(i, 1);
+ children[i] = null;
// make a new process to replace the dead one
if(options.restartChildren !== false){
- createChild(children.length);
+ createChild(i);
}
});
}

0 comments on commit 19b22a0

Please sign in to comment.