Commit 0ce87cb
authored
Avoid delays when inserting HTTP/2 handlers. (#864)
Motivation
Right now, we insert HTTP/2 handlers in a callback on a future that is
done very late. The result of this is that an entire ALPN negotiaton
_can_ complete before this callback is attached. That can in rare cases
cause the HTTP/2 handler to miss the server preamble, because it gets
added too late.
Modifications
This patch refactors the existing code to close that window. It does so
by passing a promise into the connection path and completing that
promise _on_ the event loop where we add the ALPN handlers, which should
ensure this will execute immediately when the ALPN negotiation
completes. Immportantly, we attach our promise callbacks to that promise
_before_ we hand it off, making sure the timing windows go away.
Results
Timing window is closed1 parent 353bbc8 commit 0ce87cb
File tree
2 files changed
+172
-124
lines changed- Sources/AsyncHTTPClient/ConnectionPool
- Tests/AsyncHTTPClientTests
2 files changed
+172
-124
lines changed
0 commit comments