after socket destroy, ignore all future errors

This commit is contained in:
Feross Aboukhadijeh 2015-05-17 13:53:36 -07:00
parent d0f384931f
commit 2505e13009
2 changed files with 6 additions and 0 deletions

View File

@ -87,6 +87,7 @@ UDPTracker.prototype._request = function (opts) {
} }
socket.removeListener('error', onError) socket.removeListener('error', onError)
socket.removeListener('message', onSocketMessage) socket.removeListener('message', onSocketMessage)
socket.on('error', noop) // ignore all future errors
try { socket.close() } catch (err) {} try { socket.close() } catch (err) {}
socket = null socket = null
} }
@ -261,3 +262,5 @@ function toUInt64 (n) {
} }
return Buffer.concat([common.toUInt32(0), common.toUInt32(n)]) return Buffer.concat([common.toUInt32(0), common.toUInt32(n)])
} }
function noop () {}

View File

@ -87,6 +87,7 @@ WebSocketTracker.prototype.destroy = function () {
self._onSocketDataBound = null self._onSocketDataBound = null
self._onSocketCloseBound = null self._onSocketCloseBound = null
self._socket.on('error', noop) // ignore all future errors
try { self._socket.close() } catch (e) {} try { self._socket.close() } catch (e) {}
self._socket = null self._socket = null
} }
@ -238,3 +239,5 @@ WebSocketTracker.prototype._generateOffers = function (numWant, cb) {
} }
} }
} }
function noop () {}