Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
child_process: don't emit same handle twice
Browse files Browse the repository at this point in the history
It's possible to read multiple messages off the parent/child channel.
When that happens, make sure that recvHandle is cleared after emitting
the first message so it doesn't get emitted twice.
  • Loading branch information
bnoordhuis committed Mar 25, 2013
1 parent cfd0dca commit 9352c19
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/child_process.js
Expand Up @@ -337,6 +337,7 @@ function setupChannel(target, channel) {
var message = JSON.parse(json);

handleMessage(target, message, recvHandle);
recvHandle = undefined;

start = i + 1;
}
Expand Down
1 change: 1 addition & 0 deletions test/simple/test-child-process-fork-getconnections.js
Expand Up @@ -35,6 +35,7 @@ if (process.argv[2] === 'child') {
}

if (m.cmd === 'close') {
assert.equal(socket, undefined);
sockets[m.id].once('close', function() {
process.send({ id: m.id, status: 'closed' });
});
Expand Down

0 comments on commit 9352c19

Please sign in to comment.