mirror of
https://github.com/golang/net.git
synced 2026-03-31 18:37:08 +09:00
context/ctxhttp: fix data race in tests
Change-Id: If36de4de2c4fac6767aa5490e6f3d8c15531dda6 Reviewed-on: https://go-review.googlesource.com/20275 Reviewed-by: Dave Day <djd@golang.org>
This commit is contained in:
@@ -39,6 +39,11 @@ func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Resp
|
||||
}
|
||||
result := make(chan responseAndError, 1)
|
||||
|
||||
// Make local copies of test hooks closed over by goroutines below.
|
||||
// Prevents data races in tests.
|
||||
testHookDoReturned := testHookDoReturned
|
||||
testHookDidBodyClose := testHookDidBodyClose
|
||||
|
||||
go func() {
|
||||
resp, err := client.Do(req)
|
||||
testHookDoReturned()
|
||||
|
||||
Reference in New Issue
Block a user