Fix build on 32bit arch

This commit is contained in:
Vladimir Mihailenco 2018-03-07 12:20:26 +02:00
parent 063393987a
commit a64d3e1ef1
2 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,7 @@
all: testdeps all: testdeps
go test ./... go test ./...
go test ./... -short -race go test ./... -short -race
env GOOS=linux GOARCH=386 go test ./...
go vet go vet
testdeps: testdata/redis/src/redis-server testdeps: testdata/redis/src/redis-server

View File

@ -126,7 +126,7 @@ type clusterNode struct {
latency uint32 // atomic latency uint32 // atomic
generation uint32 // atomic generation uint32 // atomic
loading int64 // atomic loading uint32 // atomic
} }
func newClusterNode(clOpt *ClusterOptions, addr string) *clusterNode { func newClusterNode(clOpt *ClusterOptions, addr string) *clusterNode {
@ -171,20 +171,20 @@ func (n *clusterNode) Latency() time.Duration {
} }
func (n *clusterNode) MarkAsLoading() { func (n *clusterNode) MarkAsLoading() {
atomic.StoreInt64(&n.loading, time.Now().Unix()) atomic.StoreUint32(&n.loading, uint32(time.Now().Unix()))
} }
func (n *clusterNode) Loading() bool { func (n *clusterNode) Loading() bool {
const minute = int64(time.Minute / time.Second) const minute = int64(time.Minute / time.Second)
loading := atomic.LoadInt64(&n.loading) loading := atomic.LoadUint32(&n.loading)
if loading == 0 { if loading == 0 {
return false return false
} }
if time.Now().Unix()-loading < minute { if time.Now().Unix()-int64(loading) < minute {
return true return true
} }
atomic.StoreInt64(&n.loading, 0) atomic.StoreUint32(&n.loading, 0)
return false return false
} }