Fix data race in WaitForDataChanged

pull/3478/head
Jason Wilder 2015-07-27 15:30:22 -06:00
parent 514f36cf54
commit 95c98d1ab7
1 changed files with 5 additions and 1 deletions

View File

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