mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Use int32 for atomic ops to avoid alignment issues
From https://golang.org/pkg/sync/atomic/#pkg-note-BUG : On both ARM and x86-32, it is the caller's responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a global variable or in an allocated struct or slice can be relied upon to be 64-bit aligned.
This commit is contained in:
@@ -119,7 +119,7 @@ type ServiceClient struct {
|
||||
|
||||
// seen is 1 if Consul has ever been seen; otherise 0. Accessed with
|
||||
// atomics.
|
||||
seen int64
|
||||
seen int32
|
||||
}
|
||||
|
||||
// NewServiceClient creates a new Consul ServiceClient from an existing Consul API
|
||||
@@ -150,13 +150,13 @@ const seen = 1
|
||||
// markSeen marks Consul as having been seen (meaning at least one operation
|
||||
// has succeeded).
|
||||
func (c *ServiceClient) markSeen() {
|
||||
atomic.StoreInt64(&c.seen, seen)
|
||||
atomic.StoreInt32(&c.seen, seen)
|
||||
}
|
||||
|
||||
// hasSeen returns true if any Consul operation has ever succeeded. Useful to
|
||||
// squelch errors if Consul isn't running.
|
||||
func (c *ServiceClient) hasSeen() bool {
|
||||
return atomic.LoadInt64(&c.seen) == seen
|
||||
return atomic.LoadInt32(&c.seen) == seen
|
||||
}
|
||||
|
||||
// Run the Consul main loop which retries operations against Consul. It should
|
||||
|
||||
Reference in New Issue
Block a user