Explorar o código

Raft HTTP: fix pause/resume race condition

Nima Yahyazadeh %!s(int64=7) %!d(string=hai) anos
pai
achega
b1812a410f
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      etcdserver/api/rafthttp/transport.go

+ 4 - 0
etcdserver/api/rafthttp/transport.go

@@ -437,12 +437,16 @@ type Pausable interface {
 }
 
 func (t *Transport) Pause() {
+	t.mu.RLock()
+	defer t.mu.RUnlock()
 	for _, p := range t.peers {
 		p.(Pausable).Pause()
 	}
 }
 
 func (t *Transport) Resume() {
+	t.mu.RLock()
+	defer t.mu.RUnlock()
 	for _, p := range t.peers {
 		p.(Pausable).Resume()
 	}