diff options
author | Brian White <mscdex@mscdex.net> | 2017-06-04 20:12:48 -0400 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-06-09 01:38:21 -0400 |
commit | dd83d118697071b7b3191d4124930d3427450fda (patch) | |
tree | ee914258fa687241c7be40deb1dc6268a75a2bab | |
parent | 8f91aa506a3d3162ffc891a092feef24104f27f5 (diff) | |
download | android-node-v8-dd83d118697071b7b3191d4124930d3427450fda.tar.gz android-node-v8-dd83d118697071b7b3191d4124930d3427450fda.tar.bz2 android-node-v8-dd83d118697071b7b3191d4124930d3427450fda.zip |
child_process: simplify send() result handling
PR-URL: https://github.com/nodejs/node/pull/13459
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
-rw-r--r-- | lib/internal/child_process.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index abd4b16d12..68dd1145d3 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -645,16 +645,15 @@ function setupChannel(target, channel) { obj.postSend(handle, options, target); } - req.oncomplete = function() { - if (this.async === true) + if (req.async) { + req.oncomplete = function() { control.unref(); - if (typeof callback === 'function') - callback(null); - }; - if (req.async === true) { + if (typeof callback === 'function') + callback(null); + }; control.ref(); - } else { - process.nextTick(function() { req.oncomplete(); }); + } else if (typeof callback === 'function') { + process.nextTick(callback, null); } } else { // Cleanup handle on error |