]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Track posted message type counts
authorMatt Joiner <anacrolix@gmail.com>
Tue, 9 Feb 2016 13:45:47 +0000 (00:45 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 9 Feb 2016 13:45:47 +0000 (00:45 +1100)
client.go
connection.go

index ad5ae2e02ec0d01f83efb07c120e9e23d8e54092..663d1a01319ab1e1912a8b3c3ebb90491f12ac45 100644 (file)
--- a/client.go
+++ b/client.go
@@ -71,6 +71,8 @@ var (
        receivedMessageTypes       = expvar.NewMap("receivedMessageTypes")
        receivedKeepalives         = expvar.NewInt("receivedKeepalives")
        supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
+       postedMessageTypes         = expvar.NewMap("postedMessageTypes")
+       postedKeepalives           = expvar.NewInt("postedKeepalives")
 )
 
 const (
index a3e6041ad3d031588e9f48c2e6a2dcd012d3f704..a140e24c7a50847b7ff4199fc7023ce403b8e657 100644 (file)
@@ -10,6 +10,7 @@ import (
        "fmt"
        "io"
        "net"
+       "strconv"
        "time"
 
        "github.com/anacrolix/missinggo"
@@ -258,6 +259,7 @@ func (c *connection) PeerHasPiece(piece int) bool {
 func (c *connection) Post(msg pp.Message) {
        select {
        case c.post <- msg:
+               postedMessageTypes.Add(strconv.FormatInt(int64(msg.Type), 10), 1)
        case <-c.closed.C():
        }
 }
@@ -492,6 +494,7 @@ func (conn *connection) writeOptimizer(keepAliveDelay time.Duration) {
                                break
                        }
                        pending.PushBack(pp.Message{Keepalive: true})
+                       postedKeepalives.Add(1)
                case msg, ok := <-conn.post:
                        if !ok {
                                return