Browse Source

Merge pull request #10827 from yznima/pr-race-3.3

Raft HTTP: fix pause/resume race condition
Gyuho Lee 6 years ago
parent
commit
d12f13279f
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()
 	}