return
}
if d := time.Since(c.lastRequestUpdate); d < updateRequestsTimerDuration {
- log.Printf("spurious timer requests update [interval=%v]", d)
+ // These should be benign, Timer.Stop doesn't guarantee that its function won't run if it's
+ // already been fired.
+ torrent.Add("spurious timer requests updates", 1)
return
}
c.updateRequests(peerUpdateRequestsTimerReason)
if b == nil {
panic("data must be non-nil to trigger send")
}
+ torrent.Add("peer request data read successes", 1)
prs.data = b
c.tickleWriter()
}
// If this is maintained correctly, we might be able to support optional synchronous reading for
// chunk sending, the way it used to work.
func (c *PeerConn) peerRequestDataReadFailed(err error, r Request) {
- c.logger.WithDefaultLevel(log.Warning).Printf("error reading chunk for peer Request %v: %v", r, err)
+ torrent.Add("peer request data read failures", 1)
+ logLevel := log.Warning
+ if c.t.hasStorageCap() {
+ // It's expected that pieces might drop. See
+ // https://github.com/anacrolix/torrent/issues/702#issuecomment-1000953313.
+ logLevel = log.Debug
+ }
+ c.logger.WithDefaultLevel(logLevel).Printf("error reading chunk for peer Request %v: %v", r, err)
if c.t.closed.IsSet() {
return
}
func (t *Torrent) numActivePeers() int {
return len(t.conns) + len(t.webSeeds)
}
+
+func (t *Torrent) hasStorageCap() bool {
+ f := t.storage.Capacity
+ if f == nil {
+ return false
+ }
+ _, ok := (*f)()
+ return ok
+}