1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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.
This commit is contained in:
Nicholas O'Leary 2013-11-29 19:56:46 +00:00
parent 0bc0dc3a2b
commit 0507578c98

View File

@ -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) {
}
}
}
}
//}
}
}
}