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

Limit the number of simultaneous connections per web seed #664

Merged
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

@@ -275,7 +275,8 @@ If `opts` is specified, then the default options (shown below) will be overridde
announce: [], // Torrent trackers to use (added to list in .torrent or magnet uri)
getAnnounceOpts: function, // Custom callback to allow sending extra parameters to the tracker
path: String, // Folder to download files to (default=`/tmp/webtorrent/`)
store: Function // Custom chunk store (must follow [abstract-chunk-store](https://www.npmjs.com/package/abstract-chunk-store) API)
store: Function, // Custom chunk store (must follow [abstract-chunk-store](https://www.npmjs.com/package/abstract-chunk-store) API)
maxWebConns: Number // Max number of simultaneous connections per web seed
}
```
@@ -76,6 +76,8 @@ function Torrent (torrentId, client, opts) {

this.strategy = opts.strategy || 'sequential'

this.maxWebConns = opts.maxWebConns

this._rechokeNumSlots = (opts.uploads === false || opts.uploads === 0)
? 0
: (+opts.uploads || 10)
@@ -1127,7 +1129,11 @@ Torrent.prototype._request = function (wire, index, hotswap) {
if (self.bitfield.get(index)) return false

var maxOutstandingRequests = getPipelineLength(wire, PIPELINE_MAX_DURATION)
if (isWebSeed && maxOutstandingRequests > 2) maxOutstandingRequests -= 2 // A webseed will handle it's real max requests
if (isWebSeed) {
// A webseed will handle it's real max requests
if (maxOutstandingRequests > 2) maxOutstandingRequests -= 2
if (self.maxWebConns) maxOutstandingRequests = Math.min(maxOutstandingRequests, self.maxWebConns)
}
if (numRequests >= maxOutstandingRequests) return false
// var endGame = (wire.requests.length === 0 && self.store.numMissing < 30)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.