wal/wal.go: modified WAL.SaveSnapshot to do the Marshal before aquiring the mutex

This commit is contained in:
Vimal Kumar 2016-09-28 10:35:19 +05:30
parent 7d9355ffba
commit f4ec303d1b

View File

@ -567,10 +567,11 @@ func (w *WAL) Save(st raftpb.HardState, ents []raftpb.Entry) error {
}
func (w *WAL) SaveSnapshot(e walpb.Snapshot) error {
b := pbutil.MustMarshal(&e)
w.mu.Lock()
defer w.mu.Unlock()
b := pbutil.MustMarshal(&e)
rec := &walpb.Record{Type: snapshotType, Data: b}
if err := w.encoder.encode(rec); err != nil {
return err