diff --git a/changelog.md b/changelog.md index 99a2da98f1..22eb803437 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,18 @@ Changelog ========= +## v0.5.4 - February 11, 2011 + +Fix excess memory consumption from Queue backing store. + +Thanks to Gustaf Sjöberg. + +## v0.5.3 - February 5, 2011 + +Fix multi/exec error reply callback logic. + +Thanks to Stella Laurenzo. + ## v0.5.2 - January 18, 2011 Fix bug where unhandled error replies confuse the parser. diff --git a/index.js b/index.js index 563d63eb1b..532a855411 100644 --- a/index.js +++ b/index.js @@ -112,6 +112,8 @@ function RedisClient(stream, options) { } self.send_command(command_obj.command, command_obj.args, command_obj.callback); } + self.offline_queue = new Queue(); + // Even though items were shifted off, Queue backing store still uses memory until next add }); this.stream.on("data", function (buffer_from_socket) { @@ -133,6 +135,14 @@ function RedisClient(stream, options) { args[2](message); } }); + self.offline_queue = new Queue(); + + self.command_queue.forEach(function (args) { + if (typeof args[2] === "function") { + args[2](message); + } + }); + self.command_queue = new Queue(); self.connected = false; self.emit("error", new Error(message)); @@ -183,6 +193,7 @@ RedisClient.prototype.connection_gone = function (why) { args[2]("Server connection closed"); } }); + self.command_queue = new Queue(); // If this is a requested shutdown, then don't retry if (self.closing) { @@ -229,6 +240,7 @@ RedisClient.prototype.return_error = function (err) { if (this.subscriptions === false && this.command_queue.length === 0) { this.emit("idle"); + this.command_queue = new Queue(); } if (command_obj && typeof command_obj.callback === "function") { @@ -255,6 +267,7 @@ RedisClient.prototype.return_reply = function (reply) { if (this.subscriptions === false && this.command_queue.length === 0) { this.emit("idle"); + this.command_queue = new Queue(); } if (command_obj && !command_obj.sub_command) { diff --git a/package.json b/package.json index a5a593e676..89771956cd 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name" : "redis", - "version" : "0.5.3", + "version" : "0.5.4", "description" : "Redis client library", "author": "Matt Ranney ", "contributors": [