]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/peer.go
Align statistics counters for correct sync.atomic work on 32-bit systems
[govpn.git] / src / cypherpunks.ru / govpn / peer.go
index 4b48cec43ee983f082de34d8569ec8133d56dc1b..a9c0aaae8dbe386dad397e2df97aaea3a7ee9d03 100644 (file)
@@ -64,6 +64,19 @@ func newNonceCipher(key *[32]byte) *xtea.Cipher {
 }
 
 type Peer struct {
+       // Statistics (they are at the beginning for correct int64 alignment)
+       BytesIn         uint64
+       BytesOut        uint64
+       BytesPayloadIn  uint64
+       BytesPayloadOut uint64
+       FramesIn        uint64
+       FramesOut       uint64
+       FramesUnauth    uint64
+       FramesDup       uint64
+       HeartbeatRecv   uint64
+       HeartbeatSent   uint64
+
+       // Basic
        Addr string
        Id   *PeerId
        Conn io.Writer
@@ -95,18 +108,6 @@ type Peer struct {
        LastSent      time.Time
        willSentCycle time.Time
 
-       // Statistics
-       BytesIn         uint64
-       BytesOut        uint64
-       BytesPayloadIn  uint64
-       BytesPayloadOut uint64
-       FramesIn        uint64
-       FramesOut       uint64
-       FramesUnauth    uint64
-       FramesDup       uint64
-       HeartbeatRecv   uint64
-       HeartbeatSent   uint64
-
        // Receiver
        BusyR    sync.Mutex `json:"-"`
        bufR     []byte