mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-10 04:30:20 +02:00
hotfix(pmtud/tcp): fix rare race condition
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user