mirror of
https://github.com/mailgun/groupcache.git
synced 2024-07-01 02:19:12 +00:00
fix overflow in peer selection
This commit is contained in:
parent
b3105e2311
commit
3f89d3eb33
6
http.go
6
http.go
|
@ -90,7 +90,11 @@ func (p *HTTPPool) PickPeer(key string) (ProtoGetter, bool) {
|
|||
if len(p.peers) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
if peer := p.peers[int(h)%len(p.peers)]; peer != p.self {
|
||||
n := int(h)
|
||||
if n < 0 {
|
||||
n *= -1
|
||||
}
|
||||
if peer := p.peers[n%len(p.peers)]; peer != p.self {
|
||||
// TODO: pre-build a slice of *httpGetter when Set()
|
||||
// is called to avoid these two allocations.
|
||||
return &httpGetter{p.Transport, peer + p.basePath}, true
|
||||
|
|
Loading…
Reference in New Issue
Block a user