Browse Source

Raft HTTP: fix pause/resume race condition

(cherry picked from commit b1812a410fbca6fb77bf95b496408c7b75d0a370)
Nima Yahyazadeh 6 years ago
parent
commit
9f1d6ca1c9
1 changed files with 4 additions and 0 deletions
  1. 4 0
      rafthttp/transport.go

+ 4 - 0
rafthttp/transport.go

@@ -372,12 +372,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()
 	}