Browse Source

Raft HTTP: fix pause/resume race condition

Nima Yahyazadeh 6 năm trước cách đây
mục cha
commit
b1812a410f
1 tập tin đã thay đổi với 4 bổ sung0 xóa
  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()
 	}