// Webseed requests are issued globally so per-connection reasons or handling make no sense.
func (me *webseedPeer) onNeedUpdateRequests(reason updateRequestReason) {
- me.peer.cl.scheduleImmediateWebseedRequestUpdate(reason)
+ // Too many reasons here: Can't predictably determine when we need to rerun updates.
+ //me.peer.cl.scheduleImmediateWebseedRequestUpdate(reason)
}
func (me *webseedPeer) expectingChunks() bool {
// Delete this entry after waiting above on an error, to prevent more requests.
ws.deleteActiveRequest(webseedRequest)
cl := ws.peer.cl
- if err == nil && cl.numWebSeedRequests[ws.hostKey] <= webseedHostRequestConcurrency/2 {
+ if err == nil && cl.numWebSeedRequests[ws.hostKey] == webseedHostRequestConcurrency/2 {
cl.updateWebseedRequestsWithReason("webseedPeer request completed")
}
locker.Unlock()
- Initiate missing requests that fit into the available limits.
*/
func (cl *Client) updateWebseedRequests() {
- if webseed.PrintDebug {
- started := time.Now()
- defer func() {
- now := time.Now()
- fmt.Printf("%v: updateWebseedRequests took %v\n", time.Now(), now.Sub(started))
- }()
- }
type aprioriMapValue struct {
startIndex RequestIndex
webseedRequestOrderValue
pprof.Do(context.Background(), pprof.Labels(
"reason", string(cl.webseedUpdateReason),
), func(_ context.Context) {
- cl.updateWebseedRequests()
+ started := time.Now()
+ reason := cl.webseedUpdateReason
cl.webseedUpdateReason = ""
+ cl.updateWebseedRequests()
+ panicif.NotZero(cl.webseedUpdateReason)
+ if webseed.PrintDebug {
+ now := time.Now()
+ fmt.Printf("%v: updateWebseedRequests took %v (reason: %v)\n", now, now.Sub(started), reason)
+ }
})
// Timer should always be stopped before the last call. TODO: Don't reset timer if there's
// nothing to do (no possible requests in update).
return ErrBadResponse{"resp status ok but requested range", resp}
}
if discard != 0 {
+ if PrintDebug {
+ fmt.Printf("resp status ok but requested range [url=%q, range=%q]",
+ part.req.URL,
+ part.req.Header.Get("Range"))
+ }
log.Printf("resp status ok but requested range [url=%q, range=%q]",
part.req.URL,
part.req.Header.Get("Range"))