Переглянути джерело

raft: return empty status if node is stopped

If the node is stopped, then Status can hang forever because there is no
event loop to answer. So, just return empty status to avoid deadlocks.

Fix #6855

Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
Alexander Morozov 9 роки тому
батько
коміт
7afc490c95
1 змінених файлів з 6 додано та 2 видалено
  1. 6 2
      raft/node.go

+ 6 - 2
raft/node.go

@@ -462,8 +462,12 @@ func (n *node) ApplyConfChange(cc pb.ConfChange) *pb.ConfState {
 
 
 func (n *node) Status() Status {
 func (n *node) Status() Status {
 	c := make(chan Status)
 	c := make(chan Status)
-	n.status <- c
-	return <-c
+	select {
+	case n.status <- c:
+		return <-c
+	case <-n.done:
+		return Status{}
+	}
 }
 }
 
 
 func (n *node) ReportUnreachable(id uint64) {
 func (n *node) ReportUnreachable(id uint64) {