Skip to content

Commit

Permalink
Fix build on 32bit arch
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Mar 7, 2018
1 parent 0633939 commit a64d3e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit a64d3e1

Please sign in to comment.