http2: fix race in TestCanonicalHeaderCacheGrowth
As Damien found in the 2nd patch set of CL 455736 and CL 455735,
disableGoroutineTracking is racy (but only called by benchmarks
that don't care); set the serverConn.serveG in the test instead.
Fixes golang/go#57218.
Change-Id: I5e39be3c7fbac93260a26951491863b06b39d672
Reviewed-on: https://go-review.googlesource.com/c/net/+/456523
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
diff --git a/http2/server_test.go b/http2/server_test.go
index a1e086c..815efe1 100644
--- a/http2/server_test.go
+++ b/http2/server_test.go
@@ -4547,10 +4547,11 @@
// TestCanonicalHeaderCacheGrowth verifies that the canonical header cache
// size is capped to a reasonable level.
func TestCanonicalHeaderCacheGrowth(t *testing.T) {
- defer disableGoroutineTracking()()
for _, size := range []int{1, (1 << 20) - 10} {
base := strings.Repeat("X", size)
- sc := &serverConn{}
+ sc := &serverConn{
+ serveG: newGoroutineLock(),
+ }
const count = 1000
for i := 0; i < count; i++ {
h := fmt.Sprintf("%v-%v", base, i)