]> Sergey Matveev's repositories - btrtrc.git/blobdiff - peer.go
Add holepunching stats and tests
[btrtrc.git] / peer.go
diff --git a/peer.go b/peer.go
index 4e2a24f60b5de6e2feb0ee981beecfbfc9806fd2..d59c5c4c336ac594b871a48dafd489f9e114a382 100644 (file)
--- a/peer.go
+++ b/peer.go
@@ -86,7 +86,6 @@ type (
                peerChoking           bool
                peerRequests          map[Request]*peerRequestState
                PeerPrefersEncryption bool // as indicated by 'e' field in extension handshake
-               PeerListenPort        int
                // The highest possible number of pieces the torrent could have based on
                // communication with the peer. Generally only useful until we have the
                // torrent info.
@@ -325,6 +324,9 @@ func (p *Peer) close() {
        if p.updateRequestsTimer != nil {
                p.updateRequestsTimer.Stop()
        }
+       for _, prs := range p.peerRequests {
+               prs.allocReservation.Drop()
+       }
        p.peerImpl.onClose()
        if p.t != nil {
                p.t.decPeerPieceAvailability(p)
@@ -520,7 +522,7 @@ func (cn *Peer) peerPiecesChanged() {
 func (cn *Peer) postHandshakeStats(f func(*ConnStats)) {
        t := cn.t
        f(&t.stats)
-       f(&t.cl.stats)
+       f(&t.cl.connStats)
 }
 
 // All ConnStats that include this connection. Some objects are not known