fix harmless race where the same value is written to a tls config concurrently

This commit is contained in:
Mechiel Lukkien
2024-04-15 20:07:39 +02:00
parent 11eaa8cd1a
commit e1dbc07dba
2 changed files with 6 additions and 2 deletions

View File

@ -772,8 +772,9 @@ func listen1(ip string, port int, tlsConfig *tls.Config, name string, kinds []st
}
server := &http.Server{
Handler: handler,
TLSConfig: tlsConfig,
Handler: handler,
// Clone because our multiple Server.Serve calls modify config concurrently leading to data race.
TLSConfig: tlsConfig.Clone(),
ReadHeaderTimeout: 30 * time.Second,
IdleTimeout: 65 * time.Second, // Chrome closes connections after 60 seconds, firefox after 115 seconds.
ErrorLog: golog.New(mlog.LogWriter(pkglog.With(slog.String("pkg", "net/http")), slog.LevelInfo, protocol+" error"), "", 0),