aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-04-07 15:37:18 +0000
committerGopher Robot <gobot@golang.org>2023-04-07 16:45:25 +0000
commit38dadcc3b5e0f0ed70d224f1eb519a83dcdb52de (patch)
treef8433dbb12011f3b90394980679ff407eb960033 /src/net/http
parent39986d28e435d23e1d1dc41b8f16c0cf30181208 (diff)
downloadgo-38dadcc3b5e0f0ed70d224f1eb519a83dcdb52de.tar.xz
net/http: fix a race in TestResponseControllerSetPastReadDeadline
If the Write goroutine is delayed for long enough after its first Write, the handler may have closed both the readc and donec channels by the time it selects over them, and the donec case may be randomly chosen. Handle that case by explicitly checking readc as well. This fixes a race accidentally introduced in CL 482935 and observed in https://build.golang.org/log/fa684750994d1fda409722f144b90c65b4c52cf9. For #59447. Change-Id: I5c87a599910cf8c1d037e5bbce68bf35afd55d61 Reviewed-on: https://go-review.googlesource.com/c/go/+/483036 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/responsecontroller_test.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net/http/responsecontroller_test.go b/src/net/http/responsecontroller_test.go
index c560e4bc54..5828f3795a 100644
--- a/src/net/http/responsecontroller_test.go
+++ b/src/net/http/responsecontroller_test.go
@@ -199,8 +199,12 @@ func testResponseControllerSetPastReadDeadline(t *testing.T, mode testMode) {
select {
case <-readc:
case <-donec:
- t.Errorf("server handler unexpectedly exited without closing readc")
- return
+ select {
+ case <-readc:
+ default:
+ t.Errorf("server handler unexpectedly exited without closing readc")
+ return
+ }
}
pw.Write([]byte("two"))
}()