From 0507578c9874ace57c08d13d4c519868f77ac9d4 Mon Sep 17 00:00:00 2001 From: Nicholas O'Leary Date: Fri, 29 Nov 2013 19:56:46 +0000 Subject: [PATCH] Always clone messages to ensure no cross-pollution Part of #85 A function that returns the same message to multiple outputs, where each output is wired to at most one node was not having its messages cloned due to the change I made in #85 to be slightly more efficient. By returning the same message to each output, cross pollution was possible. --- red/nodes.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/red/nodes.js b/red/nodes.js index 3265f2dc4..0eb50f352 100644 --- a/red/nodes.js +++ b/red/nodes.js @@ -155,16 +155,16 @@ Node.prototype.send = function(msg) { if (!util.isArray(msg[i])) { msgs = [msg[i]]; } - if (wires.length == 1) { - // Single recipient, don't need to clone the message - var node = registry.get(wires[0]); - if (node) { - for (var k in msgs) { - var mm = msgs[k]; - node.receive(mm); - } - } - } else { + //if (wires.length == 1) { + // // Single recipient, don't need to clone the message + // var node = registry.get(wires[0]); + // if (node) { + // for (var k in msgs) { + // var mm = msgs[k]; + // node.receive(mm); + // } + // } + //} else { // Multiple recipients, must send message copies for (var j in wires) { var node = registry.get(wires[j]); @@ -184,7 +184,7 @@ Node.prototype.send = function(msg) { } } } - } + //} } } }