Browse Source

Merge pull request #10826 from yznima/pr-race

Raft HTTP: fix pause/resume race condition
Gyuho Lee 6 years ago
parent
commit
e5876c6ce2
1 changed files with 4 additions and 0 deletions
  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()
 	}