clientv3: fix balancer update address bug

This commit is contained in:
fanmin shi 2017-01-26 12:12:08 -08:00
parent 094be295a1
commit 0c4e67c1f4

View File

@ -124,7 +124,11 @@ func (b *simpleBalancer) updateAddrs(eps []string) {
addrs = append(addrs, grpc.Address{Addr: getHost(eps[i])})
}
b.addrs = addrs
b.notifyCh <- addrs
// updating notifyCh can trigger new connections,
// but balancer only expects new connections if all connections are down
if b.pinAddr == "" {
b.notifyCh <- addrs
}
}
func (b *simpleBalancer) Up(addr grpc.Address) func(error) {
@ -220,7 +224,7 @@ func (b *simpleBalancer) Close() error {
close(b.notifyCh)
b.pinAddr = ""
// In the case of follwing scenerio:
// In the case of following scenario:
// 1. upc is not closed; no pinned address
// 2. client issues an rpc, calling invoke(), which calls Get(), enters for loop, blocks
// 3. clientconn.Close() calls balancer.Close(); closed = true