raftexample: use Rlock instead of Lock in getsnapshot

This commit is contained in:
caoming 2018-09-19 09:29:48 +08:00
parent ab544f2dde
commit dd6e579b84

View File

@ -95,8 +95,8 @@ func (s *kvstore) readCommits(commitC <-chan *string, errorC <-chan error) {
}
func (s *kvstore) getSnapshot() ([]byte, error) {
s.mu.Lock()
defer s.mu.Unlock()
s.mu.RLock()
defer s.mu.RUnlock()
return json.Marshal(s.kvStore)
}