From 9e225dc6f5ede297bab34efb7afb3e28de99aa17 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 27 Jul 2013 14:53:33 +0100 Subject: [PATCH] Identd port pairs memory leak fix --- server/irc/connection.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/irc/connection.js b/server/irc/connection.js index 67b05a2..2f07ba8 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -211,12 +211,19 @@ IrcConnection.prototype.connect = function () { // Apply the socket listeners that.socket.on(socket_connect_event_name, function () { + + // SSL connections have the actual socket as a property + var socket = (typeof this.socket !== 'undefined') ? + this.socket : + this; + that.connected = true; // Make note of the port numbers for any identd lookups // Nodejs < 0.9.6 has no socket.localPort so check this first - if (this.localPort) { - global.clients.port_pairs[this.localPort.toString() + '_' + this.remotePort.toString()] = that; + if (socket.localPort) { + that.identd_port_pair = socket.localPort.toString() + '_' + socket.remotePort.toString(); + global.clients.port_pairs[that.identd_port_pair] = that; } socketConnectHandler.call(that); @@ -234,9 +241,8 @@ IrcConnection.prototype.connect = function () { that.connected = false; // Remove this socket form the identd lookup - // Nodejs < 0.9.6 has no socket.localPort so check this first - if (this.localPort) { - delete global.clients.port_pairs[this.localPort.toString() + '_' + this.remotePort.toString()]; + if (that.identd_port_pair) { + delete global.clients.port_pairs[that.identd_port_pair]; } that.emit('close'); -- 2.25.1