@marcel91200 / caddy Mirror · read-only / commits / 7f9cfcc0
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

http: Close HTTP/3 servers and listeners; upstream bug irreproducible

See https://github.com/lucas-clemente/quic-go/issues/2103 and https://github.com/caddyserver/caddy/pull/2727

Matthew Holt committed Feb 18, 2020 at 10:39 UTC 7f9cfcc0f2918ec3c01b3f0408442026be454dc2
1 file changed +21 -16
modules/caddyhttp/caddyhttp.go
+21 -16
@@ -322,22 +322,27 @@ func (app *App) Stop() error {
322 return err
323 }
324 }
325 - // TODO: Closing the http3.Server is the right thing to do,
326 - // however, doing so sometimes causes connections from clients
327 - // to fail after config reloads due to a bug that is yet
328 - // unsolved: https://github.com/caddyserver/caddy/pull/2727
329 - // for _, s := range app.h3servers {
330 - // // TODO: CloseGracefully, once implemented upstream
331 - // // (see https://github.com/lucas-clemente/quic-go/issues/2103)
332 - // err := s.Close()
333 - // if err != nil {
334 - // return err
335 - // }
336 - // }
337 - // as of September 2019, closing the http3.Server
338 - // instances doesn't close their underlying listeners
339 - // so we have todo that ourselves
340 - // (see https://github.com/lucas-clemente/quic-go/issues/2103)
325 +
326 + // close the http3 servers; it's unclear whether the bug reported in
327 + // https://github.com/caddyserver/caddy/pull/2727#issuecomment-526856566
328 + // was ever truly fixed, since it seemed racey/nondeterministic; but
329 + // recent tests in 2020 were unable to replicate the issue again after
330 + // repeated attempts (the bug manifested after a config reload; i.e.
331 + // reusing a http3 server or listener was problematic), but it seems
332 + // to be working fine now
333 + for _, s := range app.h3servers {
334 + // TODO: CloseGracefully, once implemented upstream
335 + // (see https://github.com/lucas-clemente/quic-go/issues/2103)
336 + err := s.Close()
337 + if err != nil {
338 + return err
339 + }
340 + }
341 +
342 + // closing an http3.Server does not close their underlying listeners
343 + // since apparently the listener can be used both by servers and
344 + // clients at the same time; so we need to manually call Close()
345 + // on the underlying h3 listeners (see lucas-clemente/quic-go#2103)
346 for _, pc := range app.h3listeners {
347 err := pc.Close()
348 if err != nil {