Skip to content

Commit c630661

Browse files
fraenkelgopherbot
authored andcommitted
net/http: avoid leaking the writing goroutine
The test will wait for all goroutines. A race can occur if the writing goroutine uses the Log after the test exits. For #58264 For #59883 For #59884 Change-Id: I9b8ec7c9d024ff74b922b69efa438be5a4fa3483 Reviewed-on: https://go-review.googlesource.com/c/go/+/490255 Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent 46f60d6 commit c630661

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/net/http/serve_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,13 @@ func testServerExpect(t *testing.T, mode testMode) {
17441744
// that doesn't send 100-continue expectations.
17451745
writeBody := test.contentLength != 0 && strings.ToLower(test.expectation) != "100-continue"
17461746

1747+
wg := sync.WaitGroup{}
1748+
wg.Add(1)
1749+
defer wg.Wait()
1750+
17471751
go func() {
1752+
defer wg.Done()
1753+
17481754
contentLen := fmt.Sprintf("Content-Length: %d", test.contentLength)
17491755
if test.chunked {
17501756
contentLen = "Transfer-Encoding: chunked"

0 commit comments

Comments
 (0)