mirror of https://github.com/grpc/grpc-go.git
Ensure that RoundRobin.Close() does not panic. (#1139)
This commit is contained in:
parent
2eb11e102d
commit
ffa4ec7da2
|
|
@ -385,6 +385,9 @@ func (rr *roundRobin) Notify() <-chan []Address {
|
||||||
func (rr *roundRobin) Close() error {
|
func (rr *roundRobin) Close() error {
|
||||||
rr.mu.Lock()
|
rr.mu.Lock()
|
||||||
defer rr.mu.Unlock()
|
defer rr.mu.Unlock()
|
||||||
|
if rr.done {
|
||||||
|
return errBalancerClosed
|
||||||
|
}
|
||||||
rr.done = true
|
rr.done = true
|
||||||
if rr.w != nil {
|
if rr.w != nil {
|
||||||
rr.w.Close()
|
rr.w.Close()
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,8 @@ var (
|
||||||
errConnClosing = errors.New("grpc: the connection is closing")
|
errConnClosing = errors.New("grpc: the connection is closing")
|
||||||
// errConnUnavailable indicates that the connection is unavailable.
|
// errConnUnavailable indicates that the connection is unavailable.
|
||||||
errConnUnavailable = errors.New("grpc: the connection is unavailable")
|
errConnUnavailable = errors.New("grpc: the connection is unavailable")
|
||||||
|
// errBalancerClosed indicates that the balancer is closed.
|
||||||
|
errBalancerClosed = errors.New("grpc: balancer is closed")
|
||||||
// minimum time to give a connection to complete
|
// minimum time to give a connection to complete
|
||||||
minConnectTimeout = 20 * time.Second
|
minConnectTimeout = 20 * time.Second
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue