Skip to content

Commit 6d2c4a8

Browse files
committed
net: deflake recently added TestCloseUnblocksReadUDP
Fixes golang#72802 Change-Id: I0dd457ef81a354f61c9de306e4609efdbe3d69b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/656857 Auto-Submit: Brad Fitzpatrick <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Bypass: Brad Fitzpatrick <[email protected]> (cherry picked from commit 485480f)
1 parent 8746767 commit 6d2c4a8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/net/net_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/internal/socktest"
1212
"os"
1313
"runtime"
14+
"sync"
1415
"testing"
1516
"time"
1617
)
@@ -511,11 +512,25 @@ func TestCloseUnblocksRead(t *testing.T) {
511512
// Issue 72770: verify that a blocked UDP read is woken up by a Close.
512513
func TestCloseUnblocksReadUDP(t *testing.T) {
513514
t.Parallel()
515+
var (
516+
mu sync.Mutex
517+
done bool
518+
)
519+
defer func() {
520+
mu.Lock()
521+
defer mu.Unlock()
522+
done = true
523+
}()
514524
pc, err := ListenPacket("udp", "127.0.0.1:0")
515525
if err != nil {
516526
t.Fatal(err)
517527
}
518528
time.AfterFunc(250*time.Millisecond, func() {
529+
mu.Lock()
530+
defer mu.Unlock()
531+
if done {
532+
return
533+
}
519534
t.Logf("closing conn...")
520535
pc.Close()
521536
})

0 commit comments

Comments
 (0)