From 486980b9a7694d8b6609478469d23032137d3ba0 Mon Sep 17 00:00:00 2001 From: Shuo Wu Date: Mon, 6 Jun 2022 21:24:58 +0800 Subject: [PATCH] manager: Fix the flooded broadcasting issue Signed-off-by: Shuo Wu --- pkg/manager/service.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/manager/service.go b/pkg/manager/service.go index dfe14805..80d2bccc 100644 --- a/pkg/manager/service.go +++ b/pkg/manager/service.go @@ -104,20 +104,16 @@ func (m *Manager) startBroadcasting(ctx context.Context) { defer ticker.Stop() done := false - for { + for !done { select { case <-ctx.Done(): m.log.Info("Backing Image Manager: stopped broadcasting due to context done") done = true - break case <-ticker.C: if m.checkBroadcasting() { m.broadcastCh <- nil } } - if done { - break - } } } @@ -231,7 +227,7 @@ func (m *Manager) listAndUpdate() (biFileInfoMap map[string]*api.FileInfo, err e for filePath, fInfo := range fInfoList { biName := types.GetBackingImageNameFromFilePath(filePath, fInfo.UUID) newBiFileInfoMap[biName] = fInfo - if !m.broadcastRequired && reflect.DeepEqual(m.biFileInfoMap[biName], fInfo) { + if !m.broadcastRequired && !reflect.DeepEqual(m.biFileInfoMap[biName], fInfo) { m.broadcastRequired = true } }