From 432ad769521704fe91f8801cc878842c68e0ad0c Mon Sep 17 00:00:00 2001 From: Tadge Dryja Date: Wed, 13 Apr 2016 20:51:02 -0700 Subject: [PATCH] fix memory allignment for 32-bit architectures (#668) having 3 int32s above the uint64s in the struct will cause misalignment for some 32-bit architectures. see https://golang.org/pkg/sync/atomic/#pkg-note-BUG This aligns bytesReceived and bytesSent. --- server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index cf4b8c05..b7fe2400 100644 --- a/server.go +++ b/server.go @@ -170,11 +170,12 @@ func (ps *peerState) forAllPeers(closure func(sp *serverPeer)) { // bitcoin peers. type server struct { // The following variables must only be used atomically. + // Putting the uint64s first makes them 64-bit aligned for 32-bit systems. + bytesReceived uint64 // Total bytes received from all peers since start. + bytesSent uint64 // Total bytes sent by all peers since start. started int32 shutdown int32 shutdownSched int32 - bytesReceived uint64 // Total bytes received from all peers since start. - bytesSent uint64 // Total bytes sent by all peers since start. listeners []net.Listener chainParams *chaincfg.Params