1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-18 08:26:38 +02:00

Fix data race (#2721)

This commit is contained in:
Asim Aslam 2024-07-12 09:36:43 +01:00 committed by GitHub
parent 9a7cd8ce66
commit 4c34451125
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: