Fix data race in WaitForDataChanged
parent
514f36cf54
commit
95c98d1ab7
|
@ -383,11 +383,15 @@ func (s *Store) Close() error {
|
||||||
// WaitForDataChanged will block the current goroutine until the metastore index has
|
// WaitForDataChanged will block the current goroutine until the metastore index has
|
||||||
// be updated.
|
// be updated.
|
||||||
func (s *Store) WaitForDataChanged() error {
|
func (s *Store) WaitForDataChanged() error {
|
||||||
|
s.mu.RLock()
|
||||||
|
changed := s.changed
|
||||||
|
s.mu.RUnlock()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.closing:
|
case <-s.closing:
|
||||||
return errors.New("closing")
|
return errors.New("closing")
|
||||||
case <-s.changed:
|
case <-changed:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue