Skip to content

Commit 38dadcc

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
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 <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Damien Neil <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
1 parent 39986d2 commit 38dadcc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/net/http/responsecontroller_test.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ func testResponseControllerSetPastReadDeadline(t *testing.T, mode testMode) {
199199
select {
200200
case <-readc:
201201
case <-donec:
202-
t.Errorf("server handler unexpectedly exited without closing readc")
203-
return
202+
select {
203+
case <-readc:
204+
default:
205+
t.Errorf("server handler unexpectedly exited without closing readc")
206+
return
207+
}
204208
}
205209
pw.Write([]byte("two"))
206210
}()

0 commit comments

Comments
 (0)