فهرست منبع

Merge pull request #6857 from LK4D4/non_block_status

raft: return empty status if node is stopped
Xiang Li 9 سال پیش
والد
کامیت
377f19b003
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 {
 	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) {