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>
This commit is contained in:
Brian White 2017-06-04 20:12:48 -04:00
parent 8f91aa506a
commit dd83d11869
No known key found for this signature in database
GPG Key ID: 606D7358F94DA209

View File

@ -645,16 +645,15 @@ function setupChannel(target, channel) {
obj.postSend(handle, options, target); obj.postSend(handle, options, target);
} }
req.oncomplete = function() { if (req.async) {
if (this.async === true) req.oncomplete = function() {
control.unref(); control.unref();
if (typeof callback === 'function') if (typeof callback === 'function')
callback(null); callback(null);
}; };
if (req.async === true) {
control.ref(); control.ref();
} else { } else if (typeof callback === 'function') {
process.nextTick(function() { req.oncomplete(); }); process.nextTick(callback, null);
} }
} else { } else {
// Cleanup handle on error // Cleanup handle on error