From 1aa8f1eee618cfdc09d1dfdc8b60de7828d6530a Mon Sep 17 00:00:00 2001 From: Xiang Li Date: Mon, 5 Jan 2015 12:04:25 -0800 Subject: [PATCH] rafthttp: clean up reader when failed --- rafthttp/streamer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rafthttp/streamer.go b/rafthttp/streamer.go index 3f1654e3a..942e94521 100644 --- a/rafthttp/streamer.go +++ b/rafthttp/streamer.go @@ -49,7 +49,7 @@ type stream struct { } func (s *stream) open(from, to, cid types.ID, term uint64, tr http.RoundTripper, u string, r Raft) error { - c, err := newStreamReader(from, to, cid, term, tr, u, r) + rd, err := newStreamReader(from, to, cid, term, tr, u, r) if err != nil { log.Printf("stream: error opening stream: %v", err) return err @@ -58,12 +58,13 @@ func (s *stream) open(from, to, cid types.ID, term uint64, tr http.RoundTripper, s.Lock() defer s.Unlock() if s.stopped { + rd.stop() return errors.New("stream: stopped") } if s.r != nil { panic("open: stream is open") } - s.r = c + s.r = rd return nil }