Skip to content

Commit

Permalink
Merge pull request #1 from martynsmith/master
Browse files Browse the repository at this point in the history
Fixed multiple-messages per packet parsing failure
  • Loading branch information
slyons committed Oct 13, 2011
2 parents 1cb0bf9 + a2fc60a commit 5230b53
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/collectd/protocol.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -205,13 +205,21 @@ function interpret_results(results){
break; break;
case TYPE_VALUES: case TYPE_VALUES:
v.data = obj[1]; v.data = obj[1];
val_objects.push(v); val_objects.push(clone(v));
break; break;
}; };
}); });
return [val_objects, notifications]; return [val_objects, notifications];
} }


function clone(obj) {
var new_obj = {};
Object.keys(obj).forEach(function(key) {
new_obj[key] = obj[key];
});
return new_obj;
}

exports.collectd_parse = function decode_network_packet(buf){ exports.collectd_parse = function decode_network_packet(buf){
var results = new Array(); var results = new Array();
var current_object = null; var current_object = null;
Expand Down

0 comments on commit 5230b53

Please sign in to comment.