Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create new outgoing TCP connections when torrent is done #709

Merged
merged 1 commit into from Mar 29, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -364,6 +364,8 @@ Swarm.prototype._drain = function () {
conn.on('close', function () {
if (self.destroyed) return

// TODO: If torrent is done, do not try to reconnect after a timeout

if (peer.retries >= RECONNECT_WAIT.length) {
debug(
'conn %s closed: will not re-add (max %s attempts)',
@@ -299,7 +299,11 @@ Torrent.prototype._onSwarmListening = function () {
port: self.client.torrentPort
})
self.discovery.on('error', self._onError.bind(self))
self.discovery.on('peer', self.addPeer.bind(self))
self.discovery.on('peer', function (peer) {
// Don't create new outgoing TCP connections when torrent is done
if (typeof peer === 'string' && self.done) return
self.addPeer(peer)
})

// expose discovery events
reemit(self.discovery, self, ['trackerAnnounce', 'dhtAnnounce', 'warning'])
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.