mirror of
https://github.com/logos-storage/bittorrent-tracker.git
synced 2026-05-21 15:59:30 +00:00
Fixes for PR #126
This commit is contained in:
parent
2fee125554
commit
6df64ffe06
@ -74,7 +74,7 @@ HTTPTracker.prototype.scrape = function (opts) {
|
|||||||
|
|
||||||
HTTPTracker.prototype.destroy = function (cb) {
|
HTTPTracker.prototype.destroy = function (cb) {
|
||||||
var self = this
|
var self = this
|
||||||
if (self.destroyed) return cb && cb()
|
if (self.destroyed) return cb(null)
|
||||||
self.destroyed = true
|
self.destroyed = true
|
||||||
clearInterval(self.interval)
|
clearInterval(self.interval)
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ UDPTracker.prototype.scrape = function (opts) {
|
|||||||
|
|
||||||
UDPTracker.prototype.destroy = function (cb) {
|
UDPTracker.prototype.destroy = function (cb) {
|
||||||
var self = this
|
var self = this
|
||||||
if (self.destroyed) return cb && cb()
|
if (self.destroyed) return cb(null)
|
||||||
self.destroyed = true
|
self.destroyed = true
|
||||||
clearInterval(self.interval)
|
clearInterval(self.interval)
|
||||||
|
|
||||||
|
|||||||
@ -64,9 +64,10 @@ WebSocketTracker.prototype.scrape = function (opts) {
|
|||||||
self._onSocketError(new Error('scrape not supported ' + self.announceUrl))
|
self._onSocketError(new Error('scrape not supported ' + self.announceUrl))
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocketTracker.prototype.destroy = function (onclose) {
|
WebSocketTracker.prototype.destroy = function (cb) {
|
||||||
var self = this
|
var self = this
|
||||||
if (self.destroyed) return onclose && onclose()
|
if (!cb) cb = noop
|
||||||
|
if (self.destroyed) return cb(null)
|
||||||
self.destroyed = true
|
self.destroyed = true
|
||||||
clearInterval(self.interval)
|
clearInterval(self.interval)
|
||||||
|
|
||||||
@ -84,9 +85,9 @@ WebSocketTracker.prototype.destroy = function (onclose) {
|
|||||||
|
|
||||||
self.socket.on('error', noop) // ignore all future errors
|
self.socket.on('error', noop) // ignore all future errors
|
||||||
try {
|
try {
|
||||||
self.socket.destroy(onclose)
|
self.socket.destroy(cb)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (onclose) onclose()
|
cb(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.socket = null
|
self.socket = null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user