hotfix(pmtud/tcp): fix rare race condition

This commit is contained in:
Quentin McGaw
2026-02-18 19:07:31 +00:00
parent 224618337c
commit 1c56189abc
+6 -3
View File
@@ -73,18 +73,21 @@ func pathMTUDiscover(ctx context.Context, addrPort netip.AddrPort,
doneCh := make(chan struct{}) doneCh := make(chan struct{})
for i := range tests { for i := range tests {
go func(i int) { go func(i int) {
err := runTest(runCtx, fd, tracker, addrPort, tests[i].mtu) err := runTest(runCtx, fd, tracker, src, dst, tests[i].mtu)
tests[i].ok = err == nil tests[i].ok = err == nil
doneCh <- struct{}{} doneCh <- struct{}{}
}(i) }(i)
} }
for range tests { i := 0
for i < len(tests) {
select { select {
case <-doneCh: case <-doneCh:
i++
case err := <-errCh: case err := <-errCh:
if err == nil { // timeout if err == nil { // timeout
break cancel()
continue
} }
return 0, fmt.Errorf("listening for TCP replies: %w", err) return 0, fmt.Errorf("listening for TCP replies: %w", err)
} }