mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os: force a goroutine to be scheduled on WASM
The TestRootConcurrentClose test can fail when GOARCH=WASM because of goroutine starvation. The spawned goroutine will sometimes run in a loop and never have the main goroutine be scheduled. This causes the test to fail due to a timeout. This change forces the goroutine to be scheduled with each iteration of the loop when GOARCH=WASM. For #71134 Fixes #71117 Change-Id: I4fb68907c9ac3b33bd0572d5e5db2974a3379191 Reviewed-on: https://go-review.googlesource.com/c/go/+/640195 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Carlos Amedee <carlos@golang.org>
This commit is contained in:
parent
6fc23a3cff
commit
5a46b17b5f
1 changed files with 4 additions and 0 deletions
|
|
@ -1077,6 +1077,10 @@ func TestRootConcurrentClose(t *testing.T) {
|
||||||
first = false
|
first = false
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
// TODO(go.dev/issue/71134) can lead to goroutine starvation.
|
||||||
|
runtime.Gosched()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if err := <-ch; err != nil {
|
if err := <-ch; err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue