Pull request: home: rm var shadowing, vol. 4
Closes #2803.
Squashed commit of the following:
commit cb36cc8811160bb39a32fb8eddf962d0ebe9035a
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Mar 12 14:21:46 2021 +0300
home: imp more
commit 9ea7ccec8bb293881cf724d7ad57e6744243d8b9
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Mar 12 13:58:10 2021 +0300
all: imp naming, refactor http srv shutdown
commit f29221007c16fd3e7230bf2c1ac37b365f3e29aa
Merge: 2247c05b bfbf73f3
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Mar 12 13:35:17 2021 +0300
Merge branch 'master' into 2803-shadow-4
commit 2247c05b5521346aaf362d81ccdd64fee31f1e6d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Jan 29 20:53:21 2021 +0300
home: rm var shadowing, vol. 4
This commit is contained in:
@@ -141,13 +141,11 @@ func (web *Web) TLSConfigChanged(ctx context.Context, tlsConf tlsConfigSettings)
|
||||
|
||||
web.httpsServer.cond.L.Lock()
|
||||
if web.httpsServer.server != nil {
|
||||
ctx, cancel := context.WithTimeout(ctx, shutdownTimeout)
|
||||
err = web.httpsServer.server.Shutdown(ctx)
|
||||
cancel()
|
||||
if err != nil {
|
||||
log.Debug("error while shutting down HTTP server: %s", err)
|
||||
}
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, shutdownTimeout)
|
||||
shutdownSrv(ctx, cancel, web.httpsServer.server)
|
||||
}
|
||||
|
||||
web.httpsServer.enabled = enabled
|
||||
web.httpsServer.cert = cert
|
||||
web.httpsServer.cond.Broadcast()
|
||||
@@ -206,27 +204,20 @@ func (web *Web) Start() {
|
||||
|
||||
// Close gracefully shuts down the HTTP servers.
|
||||
func (web *Web) Close(ctx context.Context) {
|
||||
log.Info("Stopping HTTP server...")
|
||||
log.Info("stopping http server...")
|
||||
|
||||
web.httpsServer.cond.L.Lock()
|
||||
web.httpsServer.shutdown = true
|
||||
web.httpsServer.cond.L.Unlock()
|
||||
|
||||
shut := func(srv *http.Server) {
|
||||
if srv == nil {
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, shutdownTimeout)
|
||||
defer cancel()
|
||||
if err := srv.Shutdown(ctx); err != nil {
|
||||
log.Debug("error while shutting down HTTP server: %s", err)
|
||||
}
|
||||
}
|
||||
var cancel context.CancelFunc
|
||||
ctx, cancel = context.WithTimeout(ctx, shutdownTimeout)
|
||||
|
||||
shut(web.httpsServer.server)
|
||||
shut(web.httpServer)
|
||||
shut(web.httpServerBeta)
|
||||
shutdownSrv(ctx, cancel, web.httpsServer.server)
|
||||
shutdownSrv(ctx, cancel, web.httpServer)
|
||||
shutdownSrv(ctx, cancel, web.httpServerBeta)
|
||||
|
||||
log.Info("Stopped HTTP server")
|
||||
log.Info("stopped http server")
|
||||
}
|
||||
|
||||
func (web *Web) tlsServerLoop() {
|
||||
|
||||
Reference in New Issue
Block a user