Explorar o código

rafthttp: add necessary locking

Xiang Li %!s(int64=10) %!d(string=hai) anos
pai
achega
56318f5433
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  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)