Skip to content

Commit 0d0b98c

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
http2: avoid goroutine starvation in TestServer_Push_RejectAfterGoAway
CL 557037 added a runtime.Gosched to prevent goroutine starvation in the wasm fake-net stack. Unfortunately, that Gosched causes the scheduler to enter a very similar starvation loop in this test. Add another runtime.Gosched to break this new loop. For golang/go#65178. Change-Id: I24b3f50dd728800462f71f27290b0d8f99d5ae5b Cq-Include-Trybots: luci.golang.try:x_net-gotip-wasip1-wasm_wasmtime,x_net-gotip-wasip1-wasm_wazero,x_net-gotip-js-wasm Reviewed-on: https://go-review.googlesource.com/c/net/+/557615 Auto-Submit: Bryan Mills <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 07e05fd commit 0d0b98c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

http2/server_push_test.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"io/ioutil"
1212
"net/http"
1313
"reflect"
14+
"runtime"
1415
"strconv"
1516
"sync"
1617
"testing"
@@ -483,11 +484,7 @@ func TestServer_Push_RejectAfterGoAway(t *testing.T) {
483484
ready := make(chan struct{})
484485
errc := make(chan error, 2)
485486
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
486-
select {
487-
case <-ready:
488-
case <-time.After(5 * time.Second):
489-
errc <- fmt.Errorf("timeout waiting for GOAWAY to be processed")
490-
}
487+
<-ready
491488
if got, want := w.(http.Pusher).Push("https://"+r.Host+"/pushed", nil), http.ErrNotSupported; got != want {
492489
errc <- fmt.Errorf("Push()=%v, want %v", got, want)
493490
}
@@ -505,6 +502,10 @@ func TestServer_Push_RejectAfterGoAway(t *testing.T) {
505502
case <-ready:
506503
return
507504
default:
505+
if runtime.GOARCH == "wasm" {
506+
// Work around https://go.dev/issue/65178 to avoid goroutine starvation.
507+
runtime.Gosched()
508+
}
508509
}
509510
st.sc.serveMsgCh <- func(loopNum int) {
510511
if !st.sc.pushEnabled {

0 commit comments

Comments
 (0)