mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
wal/wal.go: modified WAL.SaveSnapshot to do the Marshal before aquiring the mutex
This commit is contained in:
parent
7d9355ffba
commit
f4ec303d1b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user