parent
fefeef4ee9
commit
159c4a0e28
|
@ -39,6 +39,9 @@ import (
|
||||||
// Clients contain zero or more Torrents. A Client manages a blocklist, the
|
// Clients contain zero or more Torrents. A Client manages a blocklist, the
|
||||||
// TCP/UDP protocol ports, and DHT as desired.
|
// TCP/UDP protocol ports, and DHT as desired.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
// An aggregate of stats over all connections. First in struct to ensure
|
||||||
|
// 64-bit alignment of fields. See #262.
|
||||||
|
stats ConnStats
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
event sync.Cond
|
event sync.Cond
|
||||||
closed missinggo.Event
|
closed missinggo.Event
|
||||||
|
@ -62,8 +65,6 @@ type Client struct {
|
||||||
dopplegangerAddrs map[string]struct{}
|
dopplegangerAddrs map[string]struct{}
|
||||||
badPeerIPs map[string]struct{}
|
badPeerIPs map[string]struct{}
|
||||||
torrents map[metainfo.Hash]*Torrent
|
torrents map[metainfo.Hash]*Torrent
|
||||||
// An aggregate of stats over all connections.
|
|
||||||
stats ConnStats
|
|
||||||
|
|
||||||
acceptLimiter map[ipStr]int
|
acceptLimiter map[ipStr]int
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ const (
|
||||||
|
|
||||||
// Maintains the state of a connection with a peer.
|
// Maintains the state of a connection with a peer.
|
||||||
type connection struct {
|
type connection struct {
|
||||||
|
// First to ensure 64-bit alignment for atomics. See #262.
|
||||||
|
stats ConnStats
|
||||||
|
|
||||||
t *Torrent
|
t *Torrent
|
||||||
// The actual Conn, used for closing, and setting socket options.
|
// The actual Conn, used for closing, and setting socket options.
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
|
@ -55,8 +58,6 @@ type connection struct {
|
||||||
// other ConnStat instances as determined when the *Torrent became known.
|
// other ConnStat instances as determined when the *Torrent became known.
|
||||||
reconciledHandshakeStats bool
|
reconciledHandshakeStats bool
|
||||||
|
|
||||||
stats ConnStats
|
|
||||||
|
|
||||||
lastMessageReceived time.Time
|
lastMessageReceived time.Time
|
||||||
completedHandshake time.Time
|
completedHandshake time.Time
|
||||||
lastUsefulChunkReceived time.Time
|
lastUsefulChunkReceived time.Time
|
||||||
|
|
|
@ -45,6 +45,9 @@ type peersKey struct {
|
||||||
|
|
||||||
// Maintains state of torrent within a Client.
|
// Maintains state of torrent within a Client.
|
||||||
type Torrent struct {
|
type Torrent struct {
|
||||||
|
// Torrent-level aggregate statistics. First in struct to ensure 64-bit
|
||||||
|
// alignment. See #262.
|
||||||
|
stats ConnStats
|
||||||
cl *Client
|
cl *Client
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
|
|
||||||
|
@ -134,8 +137,6 @@ type Torrent struct {
|
||||||
// These "inclinations" are used to give connections preference for
|
// These "inclinations" are used to give connections preference for
|
||||||
// different pieces.
|
// different pieces.
|
||||||
connPieceInclinationPool sync.Pool
|
connPieceInclinationPool sync.Pool
|
||||||
// Torrent-level statistics.
|
|
||||||
stats ConnStats
|
|
||||||
|
|
||||||
// Count of each request across active connections.
|
// Count of each request across active connections.
|
||||||
pendingRequests map[request]int
|
pendingRequests map[request]int
|
||||||
|
|
Loading…
Reference in New Issue