fix regression: double cleanup bug

This commit is contained in:
Feross Aboukhadijeh 2015-05-17 01:47:12 -07:00
parent 89a4e07430
commit d78b678f5b
3 changed files with 5 additions and 4 deletions

View File

@ -26,6 +26,7 @@ function HTTPTracker (client, announceUrl, opts) {
debug('new http tracker %s', announceUrl) debug('new http tracker %s', announceUrl)
self.client = client self.client = client
self.destroyed = false
self._opts = opts self._opts = opts
self._announceUrl = announceUrl self._announceUrl = announceUrl

View File

@ -28,6 +28,7 @@ function UDPTracker (client, announceUrl, opts) {
debug('new udp tracker %s', announceUrl) debug('new udp tracker %s', announceUrl)
self.client = client self.client = client
self.destroyed = false
self._opts = opts self._opts = opts
self._announceUrl = announceUrl self._announceUrl = announceUrl
@ -95,10 +96,8 @@ UDPTracker.prototype._request = function (opts) {
var ms = opts.event === 'stopped' ? TIMEOUT / 10 : TIMEOUT var ms = opts.event === 'stopped' ? TIMEOUT / 10 : TIMEOUT
var timeout = setTimeout(function () { var timeout = setTimeout(function () {
timeout = null timeout = null
cleanup() if (opts.event === 'stopped') cleanup()
if (opts.event !== 'stopped') { else onError(new Error('tracker request timed out (' + opts.event + ')'))
onError(new Error('tracker request timed out'))
}
}, ms) }, ms)
if (timeout.unref) timeout.unref() if (timeout.unref) timeout.unref()

View File

@ -22,6 +22,7 @@ function WebSocketTracker (client, announceUrl, opts) {
debug('new websocket tracker %s', announceUrl) debug('new websocket tracker %s', announceUrl)
self.client = client self.client = client
self.destroyed = false
self._opts = opts self._opts = opts
self._announceUrl = announceUrl self._announceUrl = announceUrl