From 7afc490c95789c408fbc256d8e790273d331c984 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Tue, 15 Nov 2016 15:38:03 -0800 Subject: [PATCH] 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 --- raft/node.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/raft/node.go b/raft/node.go index 5fce58457..c8410fdc7 100644 --- a/raft/node.go +++ b/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) {