浏览代码

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

Vimal Kumar 9 年之前
父节点
当前提交
f4ec303d1b
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      wal/wal.go

+ 2 - 1
wal/wal.go

@@ -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