-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement http3.Server.ServeListener #3349
Conversation
ServeListener method added to http3.Server allowing serving from an existing listener ConfigureTLSConfig function added to http3 which should be used to create listeners meant for serving http3.
… context.Canceled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already looks very good to me. Thank you for working on this!
Two things:
- See my comment below regarding avoiding the massive callback?
- Can we have tests? ;) We definitely need a unit test in this package. Ideally, we'll also have an integration test in the
integrationtests
package, where we swap out the server (basically the thing that Caddy will do).
Codecov Report
@@ Coverage Diff @@
## master #3349 +/- ##
==========================================
+ Coverage 85.50% 85.52% +0.02%
==========================================
Files 135 135
Lines 9830 9837 +7
==========================================
+ Hits 8405 8413 +8
+ Misses 1047 1046 -1
Partials 378 378
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM so far, but there seems to be a race condition in one of the tests.
The tests are fixed now, doesn't seem like the CircleCI fail is related to my changes |
Thank you @renbou! |
* feat(http3): implement serving from quic.Listener ServeListener method added to http3.Server allowing serving from an existing listener ConfigureTLSConfig function added to http3 which should be used to create listeners meant for serving http3. * docs(http3): add note about using ConfigureTLSConfig to ServeListener * fix(http3): stop serving non-created listeners after Server.Close * refactor(http3): return ErrServerClosed once server closes instead of context.Canceled * feat(http3): close listeners from ServeListener as well * fix(http3): fix logger not being setup during ServeListener * test(http3): add unit tests for serving listeners * test(http3): add tests for ConfigureTLSConfig * test(http3): added server hotswapping integration test * fix: race condition in listener tests
Fixes #3347
Added a
http3.Server.ServeListener
(http3.Server.Serve
is already taken and servesnet.PacketConn
) method which is can be used to serve content on an already createdquic.EarlyListener
which works likehttp.Server.Serve
in net/http.Originally, however, it was planned for these listeners not to be closed using
http3.Server.Close
so thathttp3.Server
s can be switched between without closing/starting another listener. It turned out that this is easier implemented externally (for example Caddy uses "fake close" wrappers around listeners), since there isn't an easy way to interrupt theAccept
running inhttp3.Server.serveImpl
which was run using anquic.EarlyListener
without closing the listener.Note that
net/http
'sServer.Close
also closes the listener passed toServer.Serve
, so the behavior is even more similar this way.