-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: surface errors occurring very early in a client conn's lifetime
When we create a new connection for a request, the request should fail if the connection attempt fails. There is a race condition which can cause this to not happen: - net/http sends a request to a http2.Transport - the http2.Transport returns ErrNoCachedConn - net/http creates a new tls.Conn and passes it to the http2.Transport - the http2.Transport adds the conn to its connection pool - the connection immediately encounters an error - the http2.Transport removes the conn from its connection pool - net/http resends the request to the http2.Transport - the http2.Transport returns ErrNoCachedConn, and the process repeates If the request is sent to the http2.Transport before the connection encounters an error, then the request fails. But otherwise, we get stuck in an infinite loop of the http2.Transport asking for a new connection, receiving one, and throwing it away. To fix this, leave a dead connection in the pool for a short while if it has never had a request sent to it. If a dead connection is used for a new request, return an error and remove the connection from the pool. Change-Id: I64eb15a8f1512a6bda52db423072b945fab6f4b5 Reviewed-on: https://go-review.googlesource.com/c/net/+/625398 Reviewed-by: Brad Fitzpatrick <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]>
- Loading branch information
Showing
4 changed files
with
219 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters