mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-02-07 13:59:07 +00:00
Clear reconnect timeout on destroy
This commit is contained in:
parent
35e6eeaef2
commit
3252070328
@ -87,6 +87,7 @@ WebSocketTracker.prototype.destroy = function (cb) {
|
|||||||
if (self.destroyed) return cb(null)
|
if (self.destroyed) return cb(null)
|
||||||
self.destroyed = true
|
self.destroyed = true
|
||||||
clearInterval(self.interval)
|
clearInterval(self.interval)
|
||||||
|
clearTimeout(self.reconnectTimer)
|
||||||
|
|
||||||
if (socketPool[self.announceUrl]) socketPool[self.announceUrl].consumers--
|
if (socketPool[self.announceUrl]) socketPool[self.announceUrl].consumers--
|
||||||
|
|
||||||
@ -299,11 +300,11 @@ WebSocketTracker.prototype._startReconnectTimer = function () {
|
|||||||
var ms = Math.floor(Math.random() * RECONNECT_VARIANCE) + Math.min(Math.pow(2, self.retries) * RECONNECT_MINIMUM, RECONNECT_MAXIMUM)
|
var ms = Math.floor(Math.random() * RECONNECT_VARIANCE) + Math.min(Math.pow(2, self.retries) * RECONNECT_MINIMUM, RECONNECT_MAXIMUM)
|
||||||
|
|
||||||
self.reconnecting = true
|
self.reconnecting = true
|
||||||
var reconnectTimer = setTimeout(function () {
|
self.reconnectTimer = setTimeout(function () {
|
||||||
self.retries++
|
self.retries++
|
||||||
self._openSocket()
|
self._openSocket()
|
||||||
}, ms)
|
}, ms)
|
||||||
if (reconnectTimer.unref) reconnectTimer.unref()
|
if (self.reconnectTimer.unref) self.reconnectTimer.unref()
|
||||||
|
|
||||||
debug('reconnecting socket in %s ms', ms)
|
debug('reconnecting socket in %s ms', ms)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user