mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +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) {
|
||||
var self = this
|
||||
if (self.destroyed) return cb && cb()
|
||||
if (self.destroyed) return cb(null)
|
||||
self.destroyed = true
|
||||
clearInterval(self.interval)
|
||||
|
||||
|
@ -47,7 +47,7 @@ UDPTracker.prototype.scrape = function (opts) {
|
||||
|
||||
UDPTracker.prototype.destroy = function (cb) {
|
||||
var self = this
|
||||
if (self.destroyed) return cb && cb()
|
||||
if (self.destroyed) return cb(null)
|
||||
self.destroyed = true
|
||||
clearInterval(self.interval)
|
||||
|
||||
|
@ -64,9 +64,10 @@ WebSocketTracker.prototype.scrape = function (opts) {
|
||||
self._onSocketError(new Error('scrape not supported ' + self.announceUrl))
|
||||
}
|
||||
|
||||
WebSocketTracker.prototype.destroy = function (onclose) {
|
||||
WebSocketTracker.prototype.destroy = function (cb) {
|
||||
var self = this
|
||||
if (self.destroyed) return onclose && onclose()
|
||||
if (!cb) cb = noop
|
||||
if (self.destroyed) return cb(null)
|
||||
self.destroyed = true
|
||||
clearInterval(self.interval)
|
||||
|
||||
@ -84,9 +85,9 @@ WebSocketTracker.prototype.destroy = function (onclose) {
|
||||
|
||||
self.socket.on('error', noop) // ignore all future errors
|
||||
try {
|
||||
self.socket.destroy(onclose)
|
||||
self.socket.destroy(cb)
|
||||
} catch (err) {
|
||||
if (onclose) onclose()
|
||||
cb(null)
|
||||
}
|
||||
|
||||
self.socket = null
|
||||
|
Loading…
Reference in New Issue
Block a user