Skip to content

Commit 694bf12

Browse files
committed
http2: add newly dialed conns to the pool before signaling completion
In dialCall.dial, close the done channel to mark dial completion after adding the new connection to the clientConnPool. Fixes a race condition in TestTransportBodyReadError, where the client side of the test could observe the clientConnPool as unexpectedly containing no conns, because the new conn had not yet been added to the pool. Fixes golang/go#44304. Change-Id: I121200f9aa664fae29d0532e7fa2da47de3fe6a8 Reviewed-on: https://go-review.googlesource.com/c/net/+/410934 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent fb05da6 commit 694bf12

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

http2/client_conn_pool.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ func (p *clientConnPool) getStartDialLocked(ctx context.Context, addr string) *d
139139
func (c *dialCall) dial(ctx context.Context, addr string) {
140140
const singleUse = false // shared conn
141141
c.res, c.err = c.p.t.dialClientConn(ctx, addr, singleUse)
142-
close(c.done)
143142

144143
c.p.mu.Lock()
145144
delete(c.p.dialing, addr)
146145
if c.err == nil {
147146
c.p.addConnLocked(addr, c.res)
148147
}
149148
c.p.mu.Unlock()
149+
150+
close(c.done)
150151
}
151152

152153
// addConnIfNeeded makes a NewClientConn out of c if a connection for key doesn't

0 commit comments

Comments
 (0)