func (cl *Client) underWebSeedHttpRequestLimit(key webseedHostKeyHandle) bool {
panicif.Zero(key)
- return cl.numWebSeedRequests[key] < defaultRequestsPerWebseedHost
+ return cl.numWebSeedRequests[key] < webseedHostRequestConcurrency
}
// Check for bad arrangements. This is a candidate for an error state check method.
"fmt"
"iter"
"maps"
+ "os"
+ "strconv"
"strings"
"sync"
"unique"
"github.com/anacrolix/torrent/webseed"
)
-const defaultRequestsPerWebseedHost = 10
+var webseedHostRequestConcurrency int
+
+func init() {
+ i64, err := strconv.ParseInt(cmp.Or(os.Getenv("TORRENT_WEBSEED_HOST_REQUEST_CONCURRENCY"), "10"), 10, 0)
+ panicif.Err(err)
+ webseedHostRequestConcurrency = int(i64)
+}
type (
webseedHostKey string
// handling overhead. Need the value to avoid looking this up again.
costKey := elem.costKey
panicif.Zero(costKey)
- if len(plan.byCost[costKey]) >= defaultRequestsPerWebseedHost {
+ if len(plan.byCost[costKey]) >= webseedHostRequestConcurrency {
continue
}
g.MakeMapIfNil(&plan.byCost)