mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
rafthttp: clean up reader when failed
This commit is contained in:
parent
4938e6bff5
commit
1aa8f1eee6
@ -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 {
|
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 {
|
if err != nil {
|
||||||
log.Printf("stream: error opening stream: %v", err)
|
log.Printf("stream: error opening stream: %v", err)
|
||||||
return err
|
return err
|
||||||
@ -58,12 +58,13 @@ func (s *stream) open(from, to, cid types.ID, term uint64, tr http.RoundTripper,
|
|||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
if s.stopped {
|
if s.stopped {
|
||||||
|
rd.stop()
|
||||||
return errors.New("stream: stopped")
|
return errors.New("stream: stopped")
|
||||||
}
|
}
|
||||||
if s.r != nil {
|
if s.r != nil {
|
||||||
panic("open: stream is open")
|
panic("open: stream is open")
|
||||||
}
|
}
|
||||||
s.r = c
|
s.r = rd
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user