relocate check for shutdown in ac.tearDown() (#1723)

This commit is contained in:
lyuxuan
2017-12-15 12:03:41 -08:00
committed by GitHub
parent 5ff10c3b65
commit 98b17f20a2

View File

@ -1333,6 +1333,9 @@ func (ac *addrConn) tearDown(err error) {
ac.cancel()
ac.mu.Lock()
defer ac.mu.Unlock()
if ac.state == connectivity.Shutdown {
return
}
ac.curAddr = resolver.Address{}
if err == errConnDrain && ac.transport != nil {
// GracefulClose(...) may be executed multiple times when
@ -1341,9 +1344,6 @@ func (ac *addrConn) tearDown(err error) {
// address removal and GoAway.
ac.transport.GracefulClose()
}
if ac.state == connectivity.Shutdown {
return
}
ac.state = connectivity.Shutdown
ac.tearDownErr = err
ac.cc.handleSubConnStateChange(ac.acbw, ac.state)