1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Fix memory leak. See #723 and thx to @rahar

This commit is contained in:
Ruben Bridgewater
2015-09-18 00:56:17 +02:00
parent c846ed71d1
commit 46e2dc2de5
2 changed files with 21 additions and 21 deletions

View File

@@ -394,9 +394,25 @@ RedisClient.prototype.send_offline_queue = function () {
}
};
RedisClient.prototype.connection_gone = function (why) {
var self = this;
var retry_connection = function (self) {
debug("Retrying connection...");
self.emit("reconnecting", {
delay: self.retry_delay,
attempt: self.attempts
});
self.retry_totaltime += self.retry_delay;
self.attempts += 1;
self.retry_delay = Math.round(self.retry_delay * self.retry_backoff);
self.stream = net.createConnection(self.connectionOption);
self.install_stream_listeners();
self.retry_timer = null;
};
RedisClient.prototype.connection_gone = function (why) {
// If a retry is already in progress, just let that happen
if (this.retry_timer) {
return;
@@ -452,23 +468,7 @@ RedisClient.prototype.connection_gone = function (why) {
debug("Retry connection in " + this.retry_delay + " ms");
this.retry_timer = setTimeout(function () {
debug("Retrying connection...");
self.emit("reconnecting", {
delay: self.retry_delay,
attempt: self.attempts
});
self.retry_totaltime += self.retry_delay;
self.attempts += 1;
self.retry_delay = Math.round(self.retry_delay * self.retry_backoff);
self.stream = net.createConnection(self.connectionOption);
self.install_stream_listeners();
self.retry_timer = null;
}, this.retry_delay);
this.retry_timer = setTimeout(retry_connection, this.retry_delay, this);
};
RedisClient.prototype.on_data = function (data) {