diff options
author | Gireesh Punathil <gpunathi@in.ibm.com> | 2018-05-26 11:18:02 +0530 |
---|---|---|
committer | Gireesh Punathil <gpunathi@in.ibm.com> | 2018-05-29 17:51:55 +0530 |
commit | 397eceb6d8eae723c0edc5a9050c72b6ce98d71c (patch) | |
tree | ef3204865a91db441011efa9bfb3b64e75f0f67d /test/parallel/test-child-process-fork-closed-channel-segfault.js | |
parent | 1dae52634851c477c0cf39ccfd482c33f9243475 (diff) | |
download | android-node-v8-397eceb6d8eae723c0edc5a9050c72b6ce98d71c.tar.gz android-node-v8-397eceb6d8eae723c0edc5a9050c72b6ce98d71c.tar.bz2 android-node-v8-397eceb6d8eae723c0edc5a9050c72b6ce98d71c.zip |
test: fix worker send error
In test-child-process-fork-closed-channel-segfault.js, race condition
is observed between the server getting closed and the worker sending
a message. Accommodate the potential errors.
Earlier, the same race was observed between the client and server
and was addressed through ignoring the relevant errors through error
handler. The same mechanism is re-used for worker too.
The only difference is that the filter is applied at the callback
instead of at the worker's error listener.
Refs: https://github.com/nodejs/node/issues/3635#issuecomment-157714683
Fixes: https://github.com/nodejs/node/issues/20836
PR-URL: https://github.com/nodejs/node/pull/20973
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Matheus Marchini <matheus@sthima.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Diffstat (limited to 'test/parallel/test-child-process-fork-closed-channel-segfault.js')
-rw-r--r-- | test/parallel/test-child-process-fork-closed-channel-segfault.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/parallel/test-child-process-fork-closed-channel-segfault.js b/test/parallel/test-child-process-fork-closed-channel-segfault.js index 14cb4b8fd9..c24a62379b 100644 --- a/test/parallel/test-child-process-fork-closed-channel-segfault.js +++ b/test/parallel/test-child-process-fork-closed-channel-segfault.js @@ -31,6 +31,16 @@ const server = net .listen(0, function() { const worker = cluster.fork(); + worker.on('error', function(err) { + if ( + err.code !== 'ECONNRESET' && + err.code !== 'ECONNREFUSED' && + err.code !== 'EMFILE' + ) { + throw err; + } + }); + function send(callback) { const s = net.connect(server.address().port, function() { worker.send({}, s, callback); @@ -66,7 +76,10 @@ const server = net send(function(err) { // Ignore errors when sending the second handle because the worker // may already have exited. - if (err && err.code !== 'ERR_IPC_CHANNEL_CLOSED') { + if (err && err.code !== 'ERR_IPC_CHANNEL_CLOSED' && + err.code !== 'ECONNRESET' && + err.code !== 'ECONNREFUSED' && + err.code !== 'EMFILE') { throw err; } }); |