Pull request 1814: AG-21291-web-races

Merge in DNS/adguard-home from AG-21291-web-races to master

Squashed commit of the following:

commit 1134013f928aa5e186db3b6d0450e425cb053e9c
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Apr 11 16:52:52 2023 +0300

    home: fix web api races
This commit is contained in:
Ainar Garipov
2023-04-11 17:22:51 +03:00
parent 230d7b8c17
commit 0376afb38e
5 changed files with 45 additions and 38 deletions

View File

@@ -108,7 +108,7 @@ func (m *tlsManager) start() {
// The background context is used because the TLSConfigChanged wraps context
// with timeout on its own and shuts down the server, which handles current
// request.
Context.web.TLSConfigChanged(context.Background(), tlsConf)
Context.web.tlsConfigChanged(context.Background(), tlsConf)
}
// reload updates the configuration and restarts t.
@@ -156,7 +156,7 @@ func (m *tlsManager) reload() {
// The background context is used because the TLSConfigChanged wraps context
// with timeout on its own and shuts down the server, which handles current
// request.
Context.web.TLSConfigChanged(context.Background(), tlsConf)
Context.web.tlsConfigChanged(context.Background(), tlsConf)
}
// loadTLSConf loads and validates the TLS configuration. The returned error is
@@ -454,7 +454,7 @@ func (m *tlsManager) handleTLSConfigure(w http.ResponseWriter, r *http.Request)
// same reason.
if restartHTTPS {
go func() {
Context.web.TLSConfigChanged(context.Background(), req.tlsConfigSettings)
Context.web.tlsConfigChanged(context.Background(), req.tlsConfigSettings)
}()
}
}