Fix race in peerStore

pull/5602/head
Jason Wilder 2016-02-12 12:06:23 -07:00
parent 7ad31fa6ab
commit cd568548fd
1 changed files with 5 additions and 0 deletions

View File

@ -325,14 +325,19 @@ func (l *raftLayer) Close() error { return l.ln.Close() }
// peerStore is an in-memory implementation of raft.PeerStore
type peerStore struct {
mu sync.RWMutex
peers []string
}
func (m *peerStore) Peers() ([]string, error) {
m.mu.RLock()
defer m.mu.RUnlock()
return m.peers, nil
}
func (m *peerStore) SetPeers(peers []string) error {
m.mu.Lock()
defer m.mu.Unlock()
m.peers = peers
return nil
}