From 945b583492d0b730e9c9884056af147a89826aac Mon Sep 17 00:00:00 2001 From: Danil Uzlov Date: Mon, 19 Jun 2023 13:15:43 +0700 Subject: [PATCH] improve heal monitor cleanup Signed-off-by: Danil Uzlov --- pkg/networkservice/common/heal/eventloop.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/networkservice/common/heal/eventloop.go b/pkg/networkservice/common/heal/eventloop.go index 6b795d29c..deceb8417 100644 --- a/pkg/networkservice/common/heal/eventloop.go +++ b/pkg/networkservice/common/heal/eventloop.go @@ -34,6 +34,7 @@ import ( type eventLoop struct { heal *healClient eventLoopCtx context.Context + eventLoopCancel context.CancelFunc chainCtx context.Context conn *networkservice.Connection eventFactory begin.EventFactory @@ -81,6 +82,7 @@ func newEventLoop(ctx context.Context, cc grpc.ClientConnInterface, conn *networ cev := &eventLoop{ heal: heal, eventLoopCtx: eventLoopCtx, + eventLoopCancel: eventLoopCancel, chainCtx: ctx, conn: conn, eventFactory: ev, @@ -136,6 +138,8 @@ func (cev *eventLoop) eventLoop() { func (cev *eventLoop) waitForEvents() (needToHeal, reselect bool) { defer close(cev.monitorFinishedCh) + // make sure we stop all monitors + defer cev.eventLoopCancel() ctrlPlaneCh := cev.monitorCtrlPlane() dataPlaneCh := cev.monitorDataPlane()