summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorArtem Mikheev <30644072+renbou@users.noreply.github.com>2022-03-23 02:47:57 +0300
committerGitHub <noreply@github.com>2022-03-22 19:47:57 -0400
commitc9b5e7f77b8aac7334d81c552c583af81ba1c400 (patch)
treef1ef90ea232cb73e68f692ca504726602ab523d4 /modules/caddyhttp
parent79cbe7bfd06565d0e7ab0717119f78960ed54c08 (diff)
Fix http3 servers dying after reload (#4654)
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/app.go31
1 files changed, 5 insertions, 26 deletions
diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go
index 64cc540..d81f556 100644
--- a/modules/caddyhttp/app.go
+++ b/modules/caddyhttp/app.go
@@ -18,7 +18,6 @@ import (
"context"
"crypto/tls"
"fmt"
- "net"
"net/http"
"strconv"
"time"
@@ -116,9 +115,8 @@ type App struct {
// affect functionality.
Servers map[string]*Server `json:"servers,omitempty"`
- servers []*http.Server
- h3servers []*http3.Server
- h3listeners []net.PacketConn
+ servers []*http.Server
+ h3servers []*http3.Server
ctx caddy.Context
logger *zap.Logger
@@ -353,9 +351,9 @@ func (app *App) Start() error {
app.logger.Info("enabling experimental HTTP/3 listener",
zap.String("addr", hostport),
)
- h3ln, err := caddy.ListenPacket("udp", hostport)
+ h3ln, err := caddy.ListenQUIC(hostport, tlsCfg)
if err != nil {
- return fmt.Errorf("getting HTTP/3 UDP listener: %v", err)
+ return fmt.Errorf("getting HTTP/3 QUIC listener: %v", err)
}
h3srv := &http3.Server{
Server: &http.Server{
@@ -366,9 +364,8 @@ func (app *App) Start() error {
},
}
//nolint:errcheck
- go h3srv.Serve(h3ln)
+ go h3srv.ServeListener(h3ln)
app.h3servers = append(app.h3servers, h3srv)
- app.h3listeners = append(app.h3listeners, h3ln)
srv.h3server = h3srv
}
/////////
@@ -426,13 +423,6 @@ func (app *App) Stop() error {
}
}
- // close the http3 servers; it's unclear whether the bug reported in
- // https://github.com/caddyserver/caddy/pull/2727#issuecomment-526856566
- // was ever truly fixed, since it seemed racey/nondeterministic; but
- // recent tests in 2020 were unable to replicate the issue again after
- // repeated attempts (the bug manifested after a config reload; i.e.
- // reusing a http3 server or listener was problematic), but it seems
- // to be working fine now
for _, s := range app.h3servers {
// TODO: CloseGracefully, once implemented upstream
// (see https://github.com/lucas-clemente/quic-go/issues/2103)
@@ -441,17 +431,6 @@ func (app *App) Stop() error {
return err
}
}
-
- // closing an http3.Server does not close their underlying listeners
- // since apparently the listener can be used both by servers and
- // clients at the same time; so we need to manually call Close()
- // on the underlying h3 listeners (see lucas-clemente/quic-go#2103)
- for _, pc := range app.h3listeners {
- err := pc.Close()
- if err != nil {
- return err
- }
- }
return nil
}