From 7221c8c679b74c372c5a234479dbaa0d19479292 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Mon, 14 Oct 2024 21:35:55 +0700 Subject: [PATCH] fix context leak in timeout chain element Signed-off-by: NikitaSkrynnik --- pkg/networkservice/common/timeout/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/networkservice/common/timeout/server.go b/pkg/networkservice/common/timeout/server.go index 277028fea..71440b4d7 100644 --- a/pkg/networkservice/common/timeout/server.go +++ b/pkg/networkservice/common/timeout/server.go @@ -77,10 +77,11 @@ func (s *timeoutServer) Request(ctx context.Context, request *networkservice.Net afterCh := timeClock.After(timeClock.Until(expirationTime) - requestTimeout) go func(cancelCtx context.Context, afterCh <-chan time.Time) { + defer cancel() select { case <-cancelCtx.Done(): case <-afterCh: - eventFactory.Close(begin.CancelContext(cancelCtx)) + <-eventFactory.Close(begin.CancelContext(cancelCtx)) } }(cancelCtx, afterCh)