From a6a52cf436dfaa078dfa58dabcc2d4ac01bbbf2a Mon Sep 17 00:00:00 2001 From: George Petrov Date: Sun, 6 Nov 2016 17:37:37 +0100 Subject: [PATCH 1/2] Do not choke on web seeds Web seeds should be considered as pure uncheked seeds according to BEP19 So we should never choke on them. Otherwise when there are no other seeds, the downloads will hang --- lib/torrent.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/torrent.js b/lib/torrent.js index 579f3daa..f1ebb6db 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -1026,7 +1026,7 @@ Torrent.prototype._onWireWithMetadata = function (wire) { var timeoutId = null function onChokeTimeout () { - if (self.destroyed || wire.destroyed) return + if (self.destroyed || wire.destroyed || wire.type === 'webSeed') return if (self._numQueued > 2 * (self._numConns - self.numPeers) && wire.amInterested) { @@ -1093,8 +1093,10 @@ Torrent.prototype._onWireWithMetadata = function (wire) { wire.port(self.client.dht.address().port) } - timeoutId = setTimeout(onChokeTimeout, CHOKE_TIMEOUT) - if (timeoutId.unref) timeoutId.unref() + if (wire.type !== 'webSeed') { // do not choke on webseeds + timeoutId = setTimeout(onChokeTimeout, CHOKE_TIMEOUT) + if (timeoutId.unref) timeoutId.unref() + } wire.isSeeder = false updateSeedStatus() From 7ad2f4c077cda0c67329693c5a06ddcb637b1554 Mon Sep 17 00:00:00 2001 From: George Petrov Date: Sun, 27 Nov 2016 23:30:10 +0100 Subject: [PATCH 2/2] No need to check for webSeed in onChokeTimeout as the timeout is never set for webSeeds now --- lib/torrent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/torrent.js b/lib/torrent.js index f1ebb6db..0b695561 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -1026,7 +1026,7 @@ Torrent.prototype._onWireWithMetadata = function (wire) { var timeoutId = null function onChokeTimeout () { - if (self.destroyed || wire.destroyed || wire.type === 'webSeed') return + if (self.destroyed || wire.destroyed) return if (self._numQueued > 2 * (self._numConns - self.numPeers) && wire.amInterested) {