]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Expose TORRENT_WEBSEED_HOST_REQUEST_CONCURRENCY
authorMatt Joiner <anacrolix@gmail.com>
Wed, 30 Jul 2025 07:47:31 +0000 (17:47 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 30 Jul 2025 07:47:31 +0000 (17:47 +1000)
client.go
webseed-requesting.go

index 9a62e40d92766ae3c880e609f3ac839ee64c094f..999282cf3bdecb68ff73b847d55270d21327df18 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1931,7 +1931,7 @@ func (cl *Client) Stats() ClientStats {
 
 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.
index 6cd886554c53e81b465b82ca65986eccc5dcc0f1..a386e09187b7a139e23af5de6c1e6882a87568a7 100644 (file)
@@ -5,6 +5,8 @@ import (
        "fmt"
        "iter"
        "maps"
+       "os"
+       "strconv"
        "strings"
        "sync"
        "unique"
@@ -18,7 +20,13 @@ import (
        "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
@@ -128,7 +136,7 @@ func (cl *Client) updateWebseedRequests() {
                // 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)