From 9352c1988574cbbc8649115007200315d8f79578 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 25 Mar 2013 00:29:55 +0100 Subject: [PATCH] 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. --- lib/child_process.js | 1 + test/simple/test-child-process-fork-getconnections.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/child_process.js b/lib/child_process.js index 52435913e9..e67615d21b 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -337,6 +337,7 @@ function setupChannel(target, channel) { var message = JSON.parse(json); handleMessage(target, message, recvHandle); + recvHandle = undefined; start = i + 1; } diff --git a/test/simple/test-child-process-fork-getconnections.js b/test/simple/test-child-process-fork-getconnections.js index 326c6d9f6c..ad04dd7336 100644 --- a/test/simple/test-child-process-fork-getconnections.js +++ b/test/simple/test-child-process-fork-getconnections.js @@ -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' }); });