control/controlclient: fix deadlock in shutdown

Fixes a deadlock observed in a different repo.
Regressed in 5b3f5eabb5.

Updates tailscale/corp#14950
Updates tailscale/corp#14515
Updates tailscale/corp#14139
Updates tailscale/corp#13175

Signed-off-by: Maisem Ali <maisem@tailscale.com>
pull/9647/head
Maisem Ali 1 year ago committed by Maisem Ali
parent 5902d51ba4
commit 3655fb3ba0

@ -473,11 +473,12 @@ func (nc *NoiseClient) dial(ctx context.Context) (*noiseConn, error) {
ncc.h2cc = h2cc ncc.h2cc = h2cc
nc.mu.Lock() nc.mu.Lock()
defer nc.mu.Unlock()
if nc.closed { if nc.closed {
ncc.Close() nc.mu.Unlock()
ncc.Close() // Needs to be called without holding the lock.
return nil, errors.New("noise client closed") return nil, errors.New("noise client closed")
} }
defer nc.mu.Unlock()
mak.Set(&nc.connPool, ncc.id, ncc) mak.Set(&nc.connPool, ncc.id, ncc)
nc.last = ncc nc.last = ncc
return ncc, nil return ncc, nil

Loading…
Cancel
Save