test: fix test-child-process-fork-regr-gh-2847
It's not guaranteed that the first socket that tries to connect is the first that succeeds so the rest of assumptions made in the test are not correct. Fix it by making sure the second socket does not try to connect until the first has succeeded. The IPC channel can already be closed when sending the second socket. It should be allowed. Also, don't start sending messages until the worker is online. Fixes: https://github.com/nodejs/node/issues/8950 PR-URL: https://github.com/nodejs/node/pull/8954 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Родитель
4d6297fef0
Коммит
33e598ac5f
|
@ -49,14 +49,19 @@ var server = net.createServer(function(s) {
|
|||
server.close();
|
||||
}));
|
||||
|
||||
send();
|
||||
send(function(err) {
|
||||
// Ignore errors when sending the second handle because the worker
|
||||
// may already have exited.
|
||||
if (err) {
|
||||
if (err.code !== 'ECONNREFUSED') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
worker.on('online', function() {
|
||||
send(function(err) {
|
||||
assert.ifError(err);
|
||||
send(function(err) {
|
||||
// Ignore errors when sending the second handle because the worker
|
||||
// may already have exited.
|
||||
if (err) {
|
||||
if ((err.message !== 'channel closed') &&
|
||||
(err.code !== 'ECONNREFUSED')) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче