fix Goroutine leak on version negotiation race with context cancel (#5203)

This commit is contained in:
Marten Seemann
2025-06-08 11:19:46 +08:00
committed by GitHub
parent 9580396fa1
commit 3a53b81692

View File

@@ -327,8 +327,9 @@ func (t *Transport) doDial(
// The error channel needs to be buffered, as the run loop will continue running
// after doDial returns (if the handshake is successful).
// Similarly, the recreateChan needs to be buffered; in case a different case is selected.
errChan := make(chan error, 1)
recreateChan := make(chan errCloseForRecreating)
recreateChan := make(chan errCloseForRecreating, 1)
go func() {
err := conn.run()
var recreateErr *errCloseForRecreating