wait for connection to shut down when the Dial context is cancelled (#4872)

This commit is contained in:
Marten Seemann
2025-01-14 00:01:57 -08:00
committed by GitHub
parent 96ce54e83f
commit fbbc3c9e30

View File

@@ -245,6 +245,11 @@ func (c *client) dial(ctx context.Context) error {
select {
case <-ctx.Done():
c.conn.destroy(nil)
// wait until the Go routine that called Connection.run() returns
select {
case <-errorChan:
case <-recreateChan:
}
return context.Cause(ctx)
case err := <-errorChan:
return err