Skip to content

Commit 6214c9d

Browse files
committed
Make callers of resetBackoff() lock the mutex
1 parent c3a3d1c commit 6214c9d

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

clientconn.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,8 @@ func (ac *addrConn) connect() error {
918918
ac.mu.Unlock()
919919
return nil
920920
}
921-
// Update the state to ensure no concurrent requests start once the lock
922-
// is released.
923-
ac.updateConnectivityState(connectivity.Connecting, nil)
924-
ac.mu.Unlock()
925921

926-
ac.resetTransport()
922+
ac.resetTransportAndUnlock()
927923
return nil
928924
}
929925

@@ -995,11 +991,9 @@ func (ac *addrConn) updateAddrs(addrs []resolver.Address) {
995991
ac.updateConnectivityState(connectivity.Idle, nil)
996992
}
997993

998-
ac.mu.Unlock()
999-
1000994
// Since we were connecting/connected, we should start a new connection
1001995
// attempt.
1002-
go ac.resetTransport()
996+
go ac.resetTransportAndUnlock()
1003997
}
1004998

1005999
// getServerName determines the serverName to be used in the connection
@@ -1234,8 +1228,7 @@ func (ac *addrConn) adjustParams(r transport.GoAwayReason) {
12341228
}
12351229
}
12361230

1237-
func (ac *addrConn) resetTransport() {
1238-
ac.mu.Lock()
1231+
func (ac *addrConn) resetTransportAndUnlock() {
12391232
acCtx := ac.ctx
12401233
if acCtx.Err() != nil {
12411234
ac.mu.Unlock()

0 commit comments

Comments
 (0)