Reduce some logging
This commit is contained in:
parent
14d636ec50
commit
f7494791d0
|
@ -1000,7 +1000,9 @@ func (c *Peer) updateRequestsTimerFunc() {
|
|||
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)
|
||||
|
|
10
peerconn.go
10
peerconn.go
|
@ -1030,6 +1030,7 @@ func (c *PeerConn) peerRequestDataReader(r Request, prs *peerRequestState) {
|
|||
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()
|
||||
}
|
||||
|
@ -1038,7 +1039,14 @@ func (c *PeerConn) peerRequestDataReader(r Request, prs *peerRequestState) {
|
|||
// 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
|
||||
}
|
||||
|
|
|
@ -2381,3 +2381,12 @@ func (t *Torrent) deleteConnWithAllPieces(p *Peer) bool {
|
|||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue