Skip to content

Commit

Permalink
Make callers of resetBackoff() lock the mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Jul 8, 2024
1 parent c3a3d1c commit 375bdd7
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,8 @@ func (ac *addrConn) connect() error {
ac.mu.Unlock()
return nil
}
// Update the state to ensure no concurrent requests start once the lock
// is released.
ac.updateConnectivityState(connectivity.Connecting, nil)
ac.mu.Unlock()

ac.resetTransport()
ac.resetTransportLockedAndUnlock()
return nil
}

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

ac.mu.Unlock()

// Since we were connecting/connected, we should start a new connection
// attempt.
go ac.resetTransport()
go ac.resetTransportLockedAndUnlock()
}

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

func (ac *addrConn) resetTransport() {
ac.mu.Lock()
func (ac *addrConn) resetTransportLockedAndUnlock() {
acCtx := ac.ctx
if acCtx.Err() != nil {
ac.mu.Unlock()
Expand Down

0 comments on commit 375bdd7

Please sign in to comment.