File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
"net/internal/socktest"
12
12
"os"
13
13
"runtime"
14
+ "sync"
14
15
"testing"
15
16
"time"
16
17
)
@@ -511,11 +512,25 @@ func TestCloseUnblocksRead(t *testing.T) {
511
512
// Issue 72770: verify that a blocked UDP read is woken up by a Close.
512
513
func TestCloseUnblocksReadUDP (t * testing.T ) {
513
514
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
+ }()
514
524
pc , err := ListenPacket ("udp" , "127.0.0.1:0" )
515
525
if err != nil {
516
526
t .Fatal (err )
517
527
}
518
528
time .AfterFunc (250 * time .Millisecond , func () {
529
+ mu .Lock ()
530
+ defer mu .Unlock ()
531
+ if done {
532
+ return
533
+ }
519
534
t .Logf ("closing conn..." )
520
535
pc .Close ()
521
536
})
You can’t perform that action at this time.
0 commit comments