2
0
mirror of synced 2025-02-23 22:28:11 +00:00

Add a counter for optimized cancels

This commit is contained in:
Matt Joiner 2014-08-24 03:04:07 +10:00
parent c1896c4d46
commit 1ff7414869

View File

@ -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
}
}