raft: make memory storage set method thread safe

This commit is contained in:
杜军 2016-12-20 18:48:52 +08:00
parent d62ce55584
commit 8151d4d0bc

View File

@ -98,6 +98,8 @@ func (ms *MemoryStorage) InitialState() (pb.HardState, pb.ConfState, error) {
// SetHardState saves the current HardState.
func (ms *MemoryStorage) SetHardState(st pb.HardState) error {
ms.Lock()
defer ms.Unlock()
ms.hardState = st
return nil
}