Просмотр исходного кода

rafthttp: add necessary locking

Xiang Li 10 лет назад
Родитель
Сommit
56318f5433
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      rafthttp/transport.go

+ 2 - 0
rafthttp/transport.go

@@ -289,6 +289,8 @@ func (t *Transport) ActiveSince(id types.ID) time.Time {
 }
 }
 
 
 func (t *Transport) SendSnapshot(m snap.Message) {
 func (t *Transport) SendSnapshot(m snap.Message) {
+	t.mu.Lock()
+	defer t.mu.Unlock()
 	p := t.peers[types.ID(m.To)]
 	p := t.peers[types.ID(m.To)]
 	if p == nil {
 	if p == nil {
 		m.CloseWithError(errMemberNotFound)
 		m.CloseWithError(errMemberNotFound)