Skip to content

Commit

Permalink
wal/wal.go: modified WAL.SaveSnapshot to do the Marshal before aquiri…
Browse files Browse the repository at this point in the history
…ng the mutex
  • Loading branch information
vimalk78 committed Sep 28, 2016
1 parent 7d9355f commit f4ec303
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wal/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4ec303

Please sign in to comment.