From 580b1cf417e32e3175e0f512c1c17ba991f59031 Mon Sep 17 00:00:00 2001 From: Maxim Vladimirskiy Date: Mon, 9 Oct 2023 15:12:18 +0300 Subject: [PATCH] Cancel prev state health check on config update (merge from v3) --- pkg/server/routerfactory.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/server/routerfactory.go b/pkg/server/routerfactory.go index b4cb5109f2..7a7e588b34 100644 --- a/pkg/server/routerfactory.go +++ b/pkg/server/routerfactory.go @@ -31,6 +31,8 @@ type RouterFactory struct { chainBuilder *middleware.ChainBuilder tlsManager *tls.Manager + + cancelPrevState func() } // NewRouterFactory creates a new RouterFactory. @@ -65,7 +67,12 @@ func NewRouterFactory(staticConfiguration static.Configuration, managerFactory * // CreateRouters creates new TCPRouters and UDPRouters. func (f *RouterFactory) CreateRouters(rtConf *runtime.Configuration) (map[string]*tcprouter.Router, map[string]udptypes.Handler) { - ctx := context.Background() + if f.cancelPrevState != nil { + f.cancelPrevState() + } + + var ctx context.Context + ctx, f.cancelPrevState = context.WithCancel(context.Background()) // HTTP serviceManager := f.managerFactory.Build(rtConf)