From 2988f8b3d09fdc4a90012c12a63e6b11f16e7f2b Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Mon, 6 Nov 2023 12:15:20 +0300 Subject: [PATCH] Merging to release-4-lts: Merging to release-4.3.8: [TT-9964] Prevent new idle connections to be generated. (#5526) Merging to release-4.3.8: [TT-9964] Prevent new idle connections to be generated. (#5526) [TT-9964] Prevent new idle connections to be generated. (#5526) --- gateway/api_definition.go | 6 ++++++ gateway/api_loader.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gateway/api_definition.go b/gateway/api_definition.go index 932d38a9e9c..513f2667bcc 100644 --- a/gateway/api_definition.go +++ b/gateway/api_definition.go @@ -231,6 +231,12 @@ func (s *APISpec) Release() { if s.JSVM.VM != nil { s.JSVM.DeInit() } + + if s.HTTPTransport != nil { + // Prevent new idle connections to be generated. + s.HTTPTransport.transport.DisableKeepAlives = true + s.HTTPTransport.transport.CloseIdleConnections() + } } // Validate returns nil if s is a valid spec and an error stating why the spec is not valid. diff --git a/gateway/api_loader.go b/gateway/api_loader.go index cbb9926dcd3..5e61e3a1a59 100644 --- a/gateway/api_loader.go +++ b/gateway/api_loader.go @@ -953,7 +953,7 @@ func (gw *Gateway) loadApps(specs []*APISpec) { for _, spec := range specs { curSpec, ok := gw.apisByID[spec.APIID] - if ok && curSpec.Checksum != spec.Checksum { + if ok && shouldReloadSpec(curSpec, spec) { curSpec.Release() } }