From 8637a4bf69fc0df818d78c31f7b201a9073541ec Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Mon, 4 May 2015 07:38:21 -0700 Subject: [PATCH] rafthttp: only close streamMsgApp when updating term In all stream types, streamMsgApp needs to be closed when updating term because its stream connection can only be used under a certain term. But there is no need to close other streams, which may waste time and reduce performance. --- rafthttp/stream.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rafthttp/stream.go b/rafthttp/stream.go index 219d34e6c..f4503aae2 100644 --- a/rafthttp/stream.go +++ b/rafthttp/stream.go @@ -324,7 +324,9 @@ func (cr *streamReader) updateMsgAppTerm(term uint64) { return } cr.msgAppTerm = term - cr.close() + if cr.t == streamTypeMsgApp { + cr.close() + } } // TODO: always cancel in-flight dial and decode