| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b8cea49 commit f236b3a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -266,9 +266,10 @@ argument: `null` on success, or an `Error` object on failure. | |||
| 266 | 266 | `child.send()` emits an `'error'` event if no callback was given and the message | |
| 267 | 267 | cannot be sent, for example because the child process has already exited. | |
| 268 | 268 | ||
| 269 | - Returns `true` under normal circumstances or `false` when the backlog of | ||
| 269 | + `child.send()` returns `false` if the channel has closed or when the backlog of | ||
| 270 | 270 | unsent messages exceeds a threshold that makes it unwise to send more. | |
| 271 | - Use the callback mechanism to implement flow control. | ||
| 271 | + Otherwise, it returns `true`. Use the callback mechanism to implement flow | ||
| 272 | + control. | ||
| 272 | 273 | ||
| 273 | 274 | #### Example: sending server object | |
| 274 | 275 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -504,15 +504,15 @@ function setupChannel(target, channel) { | |||
| 504 | 504 | handle = undefined; | |
| 505 | 505 | } | |
| 506 | 506 | if (this.connected) { | |
| 507 | - this._send(message, handle, false, callback); | ||
| 508 | - return; | ||
| 507 | + return this._send(message, handle, false, callback); | ||
| 509 | 508 | } | |
| 510 | 509 | const ex = new Error('channel closed'); | |
| 511 | 510 | if (typeof callback === 'function') { | |
| 512 | 511 | process.nextTick(callback, ex); | |
| 513 | 512 | } else { | |
| 514 | 513 | this.emit('error', ex); // FIXME(bnoordhuis) Defer to next tick. | |
| 515 | 514 | } | |
| 515 | + return false; | ||
| 516 | 516 | }; | |
| 517 | 517 | ||
| 518 | 518 | target._send = function(message, handle, swallowErrors, callback) { | |
@@ -577,7 +577,7 @@ function setupChannel(target, channel) { | |||
| 577 | 577 | handle: null, | |
| 578 | 578 | message: message, | |
| 579 | 579 | }); | |
| 580 | - return; | ||
| 580 | + return this._handleQueue.length === 1; | ||
| 581 | 581 | } | |
| 582 | 582 | ||
| 583 | 583 | var req = new WriteWrap(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const fork = require('child_process').fork; | ||
| 5 | + | ||
| 6 | + const n = fork(common.fixturesDir + '/empty.js'); | ||
| 7 | + | ||
| 8 | + const rv = n.send({ hello: 'world' }); | ||
| 9 | + assert.strictEqual(rv, true); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments