mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-13 10:56:25 +00:00
fix regression: double cleanup bug
This commit is contained in:
parent
89a4e07430
commit
d78b678f5b
@ -26,6 +26,7 @@ function HTTPTracker (client, announceUrl, opts) {
|
||||
debug('new http tracker %s', announceUrl)
|
||||
|
||||
self.client = client
|
||||
self.destroyed = false
|
||||
|
||||
self._opts = opts
|
||||
self._announceUrl = announceUrl
|
||||
|
@ -28,6 +28,7 @@ function UDPTracker (client, announceUrl, opts) {
|
||||
debug('new udp tracker %s', announceUrl)
|
||||
|
||||
self.client = client
|
||||
self.destroyed = false
|
||||
|
||||
self._opts = opts
|
||||
self._announceUrl = announceUrl
|
||||
@ -95,10 +96,8 @@ UDPTracker.prototype._request = function (opts) {
|
||||
var ms = opts.event === 'stopped' ? TIMEOUT / 10 : TIMEOUT
|
||||
var timeout = setTimeout(function () {
|
||||
timeout = null
|
||||
cleanup()
|
||||
if (opts.event !== 'stopped') {
|
||||
onError(new Error('tracker request timed out'))
|
||||
}
|
||||
if (opts.event === 'stopped') cleanup()
|
||||
else onError(new Error('tracker request timed out (' + opts.event + ')'))
|
||||
}, ms)
|
||||
if (timeout.unref) timeout.unref()
|
||||
|
||||
|
@ -22,6 +22,7 @@ function WebSocketTracker (client, announceUrl, opts) {
|
||||
debug('new websocket tracker %s', announceUrl)
|
||||
|
||||
self.client = client
|
||||
self.destroyed = false
|
||||
|
||||
self._opts = opts
|
||||
self._announceUrl = announceUrl
|
||||
|
Loading…
Reference in New Issue
Block a user