Skip to content

Commit

Permalink
http2: avoid goroutine starvation in TestServer_Push_RejectAfterGoAway
Browse files Browse the repository at this point in the history
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 <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed Jan 22, 2024
1 parent 07e05fd commit 0d0b98c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions http2/server_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/ioutil"
"net/http"
"reflect"
"runtime"
"strconv"
"sync"
"testing"
Expand Down Expand Up @@ -483,11 +484,7 @@ func TestServer_Push_RejectAfterGoAway(t *testing.T) {
ready := make(chan struct{})
errc := make(chan error, 2)
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {
select {
case <-ready:
case <-time.After(5 * time.Second):
errc <- fmt.Errorf("timeout waiting for GOAWAY to be processed")
}
<-ready
if got, want := w.(http.Pusher).Push("https://"+r.Host+"/pushed", nil), http.ErrNotSupported; got != want {
errc <- fmt.Errorf("Push()=%v, want %v", got, want)
}
Expand All @@ -505,6 +502,10 @@ func TestServer_Push_RejectAfterGoAway(t *testing.T) {
case <-ready:
return
default:
if runtime.GOARCH == "wasm" {
// Work around https://go.dev/issue/65178 to avoid goroutine starvation.
runtime.Gosched()
}
}
st.sc.serveMsgCh <- func(loopNum int) {
if !st.sc.pushEnabled {
Expand Down

0 comments on commit 0d0b98c

Please sign in to comment.