From: Darren Date: Thu, 31 Jan 2013 14:28:18 +0000 (+0000) Subject: IrcServer memory leak fix X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ac24e0a7d82c32066cce331555b819a3ddcbba5b;p=KiwiIRC.git IrcServer memory leak fix --- diff --git a/server/irc/eventbinder.js b/server/irc/eventbinder.js index e3d6d1b..aae2d2e 100644 --- a/server/irc/eventbinder.js +++ b/server/irc/eventbinder.js @@ -15,7 +15,7 @@ module.exports.bindIrcEvents = function (events_scope, event_map, context, irc_c // Bind the event to `context`, storing it with the event listing if (!event_map._bound_events[event_name]) { - event_map._bound_events[event_name] = fn.bind(context); + event_map._bound_events[event_name] = _.bind(fn, context); } // Add the listener to the IRC connection object @@ -40,7 +40,9 @@ module.exports.unbindIrcEvents = function (events_scope, event_map, irc_connecti irc_connection.removeListener(namespace_prefix + event_name, event_map._bound_events[event_name]); // Remove the bound function as no longer needed - event_map._bound_events[event_name] = undefined; + delete event_map._bound_events[event_name]; } }); + + delete event_map._bound_events; }; \ No newline at end of file diff --git a/server/irc/server.js b/server/irc/server.js index 2478e20..d749846 100755 --- a/server/irc/server.js +++ b/server/irc/server.js @@ -19,7 +19,7 @@ var IrcServer = function (irc_connection, host, port) { motd_start: onMotdStart, motd: onMotd, motd_end: onMotdEnd, - error: onError_, + error: onError, password_mismatch: onPasswordMismatch, channel_redirect: onChannelRedirect, no_such_nick: onNoSuchNick, @@ -118,7 +118,7 @@ function onMotdEnd(event) { }); }; -function onError_(event) { +function onError(event) { this.irc_connection.clientEvent('irc_error', { error: 'error', reason: event.reason