From 2505e1300968e8cdbb4696ee8eb0f437269f928c Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sun, 17 May 2015 13:53:36 -0700 Subject: [PATCH] after socket destroy, ignore all future errors --- lib/udp-tracker.js | 3 +++ lib/websocket-tracker.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/udp-tracker.js b/lib/udp-tracker.js index 2b4dc12..b090da8 100644 --- a/lib/udp-tracker.js +++ b/lib/udp-tracker.js @@ -87,6 +87,7 @@ UDPTracker.prototype._request = function (opts) { } socket.removeListener('error', onError) socket.removeListener('message', onSocketMessage) + socket.on('error', noop) // ignore all future errors try { socket.close() } catch (err) {} socket = null } @@ -261,3 +262,5 @@ function toUInt64 (n) { } return Buffer.concat([common.toUInt32(0), common.toUInt32(n)]) } + +function noop () {} diff --git a/lib/websocket-tracker.js b/lib/websocket-tracker.js index 3a88959..570a78a 100644 --- a/lib/websocket-tracker.js +++ b/lib/websocket-tracker.js @@ -87,6 +87,7 @@ WebSocketTracker.prototype.destroy = function () { self._onSocketDataBound = null self._onSocketCloseBound = null + self._socket.on('error', noop) // ignore all future errors try { self._socket.close() } catch (e) {} self._socket = null } @@ -238,3 +239,5 @@ WebSocketTracker.prototype._generateOffers = function (numWant, cb) { } } } + +function noop () {}