Skip to content

Commit

Permalink
Align atomics on ARM32 (#11822)
Browse files Browse the repository at this point in the history
  • Loading branch information
xacrimon committed Apr 13, 2022
1 parent 265dc7f commit 1f74048
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions lib/backend/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lib/reversetunnel/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/srv/keepalive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,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.
Expand Down

0 comments on commit 1f74048

Please sign in to comment.