mirror of
https://github.com/nodejs/node-v0.x-archive.git
synced 2026-04-28 03:01:10 -04:00
child_process: don't emit same handle twice
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.
This commit is contained in:
@@ -337,6 +337,7 @@ function setupChannel(target, channel) {
|
|||||||
var message = JSON.parse(json);
|
var message = JSON.parse(json);
|
||||||
|
|
||||||
handleMessage(target, message, recvHandle);
|
handleMessage(target, message, recvHandle);
|
||||||
|
recvHandle = undefined;
|
||||||
|
|
||||||
start = i + 1;
|
start = i + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ if (process.argv[2] === 'child') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m.cmd === 'close') {
|
if (m.cmd === 'close') {
|
||||||
|
assert.equal(socket, undefined);
|
||||||
sockets[m.id].once('close', function() {
|
sockets[m.id].once('close', function() {
|
||||||
process.send({ id: m.id, status: 'closed' });
|
process.send({ id: m.id, status: 'closed' });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user