fix deadlock of roundrobin balancer (#1353)

This commit is contained in:
Le Van Nghia 2017-07-13 02:15:13 +09:00 committed by Menghan Li
parent 8264d619d8
commit 27b2052c95
1 changed files with 5 additions and 1 deletions

View File

@ -201,6 +201,10 @@ func (rr *roundRobin) watchAddrUpdates() error {
if rr.done { if rr.done {
return ErrClientConnClosing return ErrClientConnClosing
} }
select {
case <-rr.addrCh:
default:
}
rr.addrCh <- open rr.addrCh <- open
return nil return nil
} }
@ -223,7 +227,7 @@ func (rr *roundRobin) Start(target string, config BalancerConfig) error {
return err return err
} }
rr.w = w rr.w = w
rr.addrCh = make(chan []Address) rr.addrCh = make(chan []Address, 1)
go func() { go func() {
for { for {
if err := rr.watchAddrUpdates(); err != nil { if err := rr.watchAddrUpdates(); err != nil {