From e82fa1c5eb2eb6b7c24a786edac1105032237a0f Mon Sep 17 00:00:00 2001 From: Matt Ranney Date: Fri, 17 Sep 2010 16:21:48 -0700 Subject: [PATCH] Grow return bufer if reply is too large. --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 229d01e53a..8da23a9309 100644 --- a/index.js +++ b/index.js @@ -10,8 +10,8 @@ exports.debug_mode = false; function RedisReplyParser() { this.state = "type"; - this.return_buffer = new Buffer(16384); - this.tmp_buffer = new Buffer(512); + this.return_buffer = new Buffer(16384); // for holding replies, might grow + this.tmp_buffer = new Buffer(128); // for holding size fields events.EventEmitter.call(this); } @@ -73,7 +73,6 @@ RedisReplyParser.prototype.execute = function (incoming_buf) { } else { this.return_buffer[this.return_buffer.end] = incoming_buf[pos]; this.return_buffer.end += 1; - // TODO - check for return_buffer overflow and then grow, copy, continue, and drink. } pos += 1; break; @@ -146,8 +145,11 @@ RedisReplyParser.prototype.execute = function (incoming_buf) { } else { this.state = "bulk data"; if (this.bulk_length > this.return_buffer.length) { - console.log("Ran out of receive buffer space. Need to fix this."); - // TODO - fix this + if (exports.debug_mode) { + console.log("Growing return_buffer from " + this.return_buffer.length + " to " + this.bulk_length); + } + this.return_buffer = new Buffer(this.bulk_length); + // home the old one gets cleaned up somehow } this.return_buffer.end = 0; }