Skip to content

Commit b53810d

Browse files
committed
http2: don't count aborted streams as active in tests
Deflake TestClientConnCloseAtBody, which assumes all streams have been fully cleaned up after ClientConn.Close returns. Only count active streams, not ones in the process of aborting. Perhaps ClientConn.Close should block until all streams have been cleaned up, although this could result in Close blocking indefinitely if a stream is blocked reading from the request body. Fixes golang/go#49335. Change-Id: I172e0d3f10875191d29b24598de0abbdeb35e434 Reviewed-on: https://go-review.googlesource.com/c/net/+/361536 Trust: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent ce13745 commit b53810d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

http2/transport_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -4418,9 +4418,17 @@ func BenchmarkClientResponseHeaders(b *testing.B) {
44184418
}
44194419

44204420
func activeStreams(cc *ClientConn) int {
4421+
count := 0
44214422
cc.mu.Lock()
44224423
defer cc.mu.Unlock()
4423-
return len(cc.streams)
4424+
for _, cs := range cc.streams {
4425+
select {
4426+
case <-cs.abort:
4427+
default:
4428+
count++
4429+
}
4430+
}
4431+
return count
44244432
}
44254433

44264434
type closeMode int

0 commit comments

Comments
 (0)