From 7ff1fa36f2ba10f1e08aab34dd7b6fa4e2968eb9 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Fri, 12 Jun 2015 13:00:41 -0700 Subject: [PATCH] rafthttp: always init streamReader before return from newPeer Or etcd will panic if someone calls `setTerm()`, which uses streamReader internally, before streamReader is inited. --- rafthttp/peer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rafthttp/peer.go b/rafthttp/peer.go index 9447d2a20..8509ac5df 100644 --- a/rafthttp/peer.go +++ b/rafthttp/peer.go @@ -143,10 +143,10 @@ func startPeer(tr http.RoundTripper, urls types.URLs, local, to, cid types.ID, r } }() + p.msgAppReader = startStreamReader(tr, picker, streamTypeMsgAppV2, local, to, cid, status, p.recvc, p.propc, errorc) + reader := startStreamReader(tr, picker, streamTypeMessage, local, to, cid, status, p.recvc, p.propc, errorc) go func() { var paused bool - p.msgAppReader = startStreamReader(tr, picker, streamTypeMsgAppV2, local, to, cid, status, p.recvc, p.propc, errorc) - reader := startStreamReader(tr, picker, streamTypeMessage, local, to, cid, status, p.recvc, p.propc, errorc) for { select { case m := <-p.sendc: