From a0f62a198497a3a32905311f0d3401c28f28d0fb Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 4 Aug 2011 14:26:46 +0200 Subject: [PATCH] Timeout for handshaken clients which never connect to fix memory leak. --- lib/manager.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/manager.js b/lib/manager.js index 1d6ab58f89..1b17db2b64 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -279,6 +279,16 @@ Manager.prototype.initStore = function () { Manager.prototype.onHandshake = function (id, data) { this.handshaken[id] = data; + + // set timeout to filter clients which handshake and never connect. + if (!this.connected[id]) { + var self = this; + setTimeout(function () { + if (!self.connected[id] && self.handshaken[id]) { + delete self.handshaken[id]; + } + }, this.get('client store expiration') * 1000); + } }; /**