From e945405af7901990476857ebd76ba0bc01b4c52f Mon Sep 17 00:00:00 2001 From: asim Date: Fri, 12 Jul 2024 09:34:09 +0100 Subject: [PATCH] Fix data race --- config/loader/memory/memory.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/loader/memory/memory.go b/config/loader/memory/memory.go index 43fc67c952..62ff5601fb 100644 --- a/config/loader/memory/memory.go +++ b/config/loader/memory/memory.go @@ -40,6 +40,7 @@ type updateValue struct { } type watcher struct { + sync.Mutex value reader.Value reader reader.Reader version atomic.Value @@ -427,6 +428,9 @@ func (w *watcher) Next() (*loader.Snapshot, error) { } func (w *watcher) Stop() error { + w.Lock() + defer w.Unlock() + select { case <-w.exit: default: