Skip to content

Commit 8741050

Browse files
neildgopherbot
authored andcommitted
http2: simplify TestServer_Push_RejectAfterGoAway
Replace bespoke test synchronization with a call to synctest.Wait. Change-Id: Id082fbd3696b5b4a1839b2804ee61bb02e86a929 Reviewed-on: https://go-review.googlesource.com/c/net/+/701835 Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Nicholas Husin <[email protected]> Reviewed-by: Nicholas Husin <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 96e405c commit 8741050

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

http2/server_push_test.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import (
1212
"io"
1313
"net/http"
1414
"reflect"
15-
"runtime"
1615
"strconv"
17-
"sync"
1816
"testing"
17+
"testing/synctest"
1918
"time"
2019
)
2120

@@ -497,7 +496,6 @@ func TestServer_Push_RejectAfterGoAway(t *testing.T) {
497496
synctestTest(t, testServer_Push_RejectAfterGoAway)
498497
}
499498
func testServer_Push_RejectAfterGoAway(t testing.TB) {
500-
var readyOnce sync.Once
501499
ready := make(chan struct{})
502500
errc := make(chan error, 2)
503501
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
@@ -513,24 +511,8 @@ func testServer_Push_RejectAfterGoAway(t testing.TB) {
513511

514512
// Send GOAWAY and wait for it to be processed.
515513
st.fr.WriteGoAway(1, ErrCodeNo, nil)
516-
go func() {
517-
for {
518-
select {
519-
case <-ready:
520-
return
521-
default:
522-
if runtime.GOARCH == "wasm" {
523-
// Work around https://go.dev/issue/65178 to avoid goroutine starvation.
524-
runtime.Gosched()
525-
}
526-
}
527-
st.sc.serveMsgCh <- func(loopNum int) {
528-
if !st.sc.pushEnabled {
529-
readyOnce.Do(func() { close(ready) })
530-
}
531-
}
532-
}
533-
}()
514+
synctest.Wait()
515+
close(ready)
534516
if err := <-errc; err != nil {
535517
t.Error(err)
536518
}

0 commit comments

Comments
 (0)