Identd port pairs memory leak fix
authorDarren <darren@darrenwhitlen.com>
Sat, 27 Jul 2013 13:53:33 +0000 (14:53 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 27 Jul 2013 13:53:33 +0000 (14:53 +0100)
server/irc/connection.js

index 67b05a2dcf6721881873afdd0238d42441d4f382..2f07ba81704897015b583dded3053734bda296a8 100644 (file)
@@ -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');