From a64d3e1ef1fbd678d54138e3a0cf2c742a1056f8 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 7 Mar 2018 12:20:26 +0200 Subject: [PATCH] Fix build on 32bit arch --- Makefile | 1 + cluster.go | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d6c184e..1fbdac9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ all: testdeps go test ./... go test ./... -short -race + env GOOS=linux GOARCH=386 go test ./... go vet testdeps: testdata/redis/src/redis-server diff --git a/cluster.go b/cluster.go index 319f1e2..4175b64 100644 --- a/cluster.go +++ b/cluster.go @@ -126,7 +126,7 @@ type clusterNode struct { latency uint32 // atomic generation uint32 // atomic - loading int64 // atomic + loading uint32 // atomic } func newClusterNode(clOpt *ClusterOptions, addr string) *clusterNode { @@ -171,20 +171,20 @@ func (n *clusterNode) Latency() time.Duration { } func (n *clusterNode) MarkAsLoading() { - atomic.StoreInt64(&n.loading, time.Now().Unix()) + atomic.StoreUint32(&n.loading, uint32(time.Now().Unix())) } func (n *clusterNode) Loading() bool { const minute = int64(time.Minute / time.Second) - loading := atomic.LoadInt64(&n.loading) + loading := atomic.LoadUint32(&n.loading) if loading == 0 { return false } - if time.Now().Unix()-loading < minute { + if time.Now().Unix()-int64(loading) < minute { return true } - atomic.StoreInt64(&n.loading, 0) + atomic.StoreUint32(&n.loading, 0) return false }