Skip to content
Browse files

Fix excess memory consumption from Queue backing store.

Thanks to Gustaf Sjöberg.
  • Loading branch information...
1 parent efadbc8 commit 0f907401f09a918b38d73fb14f87a2b15e0432ef @mranney mranney committed
Showing with 26 additions and 1 deletion.
  1. +12 −0 changelog.md
  2. +13 −0 index.js
  3. +1 −1 package.json
View
12 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.
View
13 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) {
View
2 package.json
@@ -1,5 +1,5 @@
{ "name" : "redis",
- "version" : "0.5.3",
+ "version" : "0.5.4",
"description" : "Redis client library",
"author": "Matt Ranney <mjr@ranney.com>",
"contributors": [

0 comments on commit 0f90740

Please sign in to comment.
Something went wrong with that request. Please try again.