Skip to content

Commit

Permalink
child_process: simplify send() result handling
Browse files Browse the repository at this point in the history
PR-URL: #13459
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
mscdex committed Jun 9, 2017
1 parent 8f91aa5 commit dd83d11
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd83d11

Please sign in to comment.