diff --git a/lib/backend/memory/memory.go b/lib/backend/memory/memory.go index 58a384f96a498..1b78e9e2dfc94 100644 --- a/lib/backend/memory/memory.go +++ b/lib/backend/memory/memory.go @@ -113,6 +113,10 @@ func New(cfg Config) (*Memory, error) { // Memory is a memory B-Tree based backend type Memory struct { + // nextID is a next record ID + // intentionally placed first to ensure 64-bit alignment + nextID int64 + *sync.Mutex *log.Entry Config @@ -126,8 +130,6 @@ type Memory struct { // ctx is a context signalling close ctx context.Context buf *backend.CircularBuffer - // nextID is a next record ID - nextID int64 } // Close closes memory backend diff --git a/lib/reversetunnel/conn.go b/lib/reversetunnel/conn.go index 557b585f2b8fa..a0d4915217014 100644 --- a/lib/reversetunnel/conn.go +++ b/lib/reversetunnel/conn.go @@ -45,6 +45,10 @@ type connKey struct { // remoteConn holds a connection to a remote host, either node or proxy. type remoteConn struct { + // lastHeartbeat is the last time a heartbeat was received. + // intentionally placed first to ensure 64-bit alignment + lastHeartbeat int64 + *connConfig mu sync.Mutex log *logrus.Entry @@ -68,9 +72,6 @@ type remoteConn struct { // clock is used to control time in tests. clock clockwork.Clock - - // lastHeartbeat is the last time a heartbeat was received. - lastHeartbeat int64 } // connConfig is the configuration for the remoteConn. diff --git a/lib/srv/keepalive_test.go b/lib/srv/keepalive_test.go index 068bec7d36a61..cf712fa39b224 100644 --- a/lib/srv/keepalive_test.go +++ b/lib/srv/keepalive_test.go @@ -123,8 +123,8 @@ func waitForRequests(requestSender *testRequestSender, count int) error { } type testRequestSender struct { + count int64 // intentionally placed first to ensure 64-bit alignment reply bool - count int64 } func (n *testRequestSender) SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error) { diff --git a/lib/utils/conn.go b/lib/utils/conn.go index 07a47b759eff7..a0ad0611ce48b 100644 --- a/lib/utils/conn.go +++ b/lib/utils/conn.go @@ -174,8 +174,8 @@ func (r *TrackingReader) Read(b []byte) (int, error) { // written. // It's thread-safe if the underlying io.Writer is thread-safe. type TrackingWriter struct { + count uint64 // intentionally placed first to ensure 64-bit alignment w io.Writer - count uint64 } // NewTrackingWriter creates a TrackingWriter around w.