conn_stats.go | 10 +++++----- torrent.go | 2 ++ torrent_stats.go | 6 ++++-- diff --git a/conn_stats.go b/conn_stats.go index 9b0865a08051ea4a1bf61739df806642d8d4810d..3fbc00d867bbaaae1e4618fc1e94a9093506d7f0 100644 --- a/conn_stats.go +++ b/conn_stats.go @@ -10,11 +10,11 @@ pp "github.com/anacrolix/torrent/peer_protocol" ) -// Various connection-level metrics. At the Torrent level these are -// aggregates. Chunks are messages with data payloads. Data is actual torrent -// content without any overhead. Useful is something we needed locally. -// Unwanted is something we didn't ask for (but may still be useful). Written -// is things sent to the peer, and Read is stuff received from them. +// Various connection-level metrics. At the Torrent level these are aggregates. Chunks are messages +// with data payloads. Data is actual torrent content without any overhead. Useful is something we +// needed locally. Unwanted is something we didn't ask for (but may still be useful). Written is +// things sent to the peer, and Read is stuff received from them. Due to the implementation of +// Count, must be aligned on some platforms: See https://github.com/anacrolix/torrent/issues/262. type ConnStats struct { // Total bytes on the wire. Includes handshakes and encryption. BytesWritten Count diff --git a/torrent.go b/torrent.go index 42f5636e8acb071c22809bb0079c5a92f391f00d..bcd80637258df5f42220064291fb4d2958150583 100644 --- a/torrent.go +++ b/torrent.go @@ -1395,6 +1395,8 @@ t.addPeer(p) } } +// The returned TorrentStats may require alignment in memory. See +// https://github.com/anacrolix/torrent/issues/383. func (t *Torrent) Stats() TorrentStats { t.cl.rLock() defer t.cl.rUnlock() diff --git a/torrent_stats.go b/torrent_stats.go index edc4ac8ee7281310470249727e195afb9298be69..bc54e1bd2768e22ce24e0851036bf5075f630396 100644 --- a/torrent_stats.go +++ b/torrent_stats.go @@ -1,8 +1,10 @@ package torrent +// Due to ConnStats, may require special alignment on some platforms. See +// https://github.com/anacrolix/torrent/issues/383. type TorrentStats struct { - // Aggregates stats over all connections past and present. Some values may - // not have much meaning in the aggregate context. + // Aggregates stats over all connections past and present. Some values may not have much meaning + // in the aggregate context. ConnStats // Ordered by expected descending quantities (if all is well).