Skip to content

Commit

Permalink
fix: ensure updateMetaDataMs is 64-bit aligned (#2356)
Browse files Browse the repository at this point in the history
As per golang/go#41970 any 64-bit variable that is accessed atomically
must be 64-bit aligned and this can be ensured by making it the first
entry in the struct.

Fixes #2337
  • Loading branch information
dnwe authored Oct 4, 2022
1 parent 0162486 commit fb9a931
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ const (
)

type client struct {
// updateMetaDataMs stores the time at which metadata was lasted updated.
// Note: this accessed atomically so must be the first word in the struct
// as per golang/go#41970
updateMetaDataMs int64

conf *Config
closer, closed chan none // for shutting down background metadata updater

Expand All @@ -150,7 +155,6 @@ type client struct {

lock sync.RWMutex // protects access to the maps that hold cluster state.

updateMetaDataMs int64 // store update metadata time
}

// NewClient creates a new Client. It connects to one of the given broker addresses
Expand Down

0 comments on commit fb9a931

Please sign in to comment.