From 1ff7414869c5346d151188cfd0667d568db68eaf Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 24 Aug 2014 03:04:07 +1000 Subject: [PATCH] Add a counter for optimized cancels --- connection.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index 00c92da6..99931aa2 100644 --- a/connection.go +++ b/connection.go @@ -4,9 +4,9 @@ import ( "container/list" "encoding" "errors" + "expvar" "fmt" "io" - "log" "net" "sync" "time" @@ -14,6 +14,8 @@ import ( pp "bitbucket.org/anacrolix/go.torrent/peer_protocol" ) +var optimizedCancels = expvar.NewInt("optimizedCancels") + type peerSource byte const ( @@ -339,7 +341,7 @@ func (conn *connection) writeOptimizer(keepAliveDelay time.Duration) { elemMsg := e.Value.(pp.Message) if elemMsg.Type == pp.Request && msg.Index == elemMsg.Index && msg.Begin == elemMsg.Begin && msg.Length == elemMsg.Length { pending.Remove(e) - log.Printf("optimized cancel! %v", msg) + optimizedCancels.Add(1) break event } } -- 2.48.1