Skip to content

Commit

Permalink
Merge pull request #53 from getlantern/smux-issue-52
Browse files Browse the repository at this point in the history
Always stop timer in Stream.Read
  • Loading branch information
xtaci authored Jul 10, 2019
2 parents 79b3c96 + e7738d0 commit 67e00e8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,13 @@ func (s *Stream) Read(b []byte) (n int, err error) {
var deadline <-chan time.Time
if d, ok := s.readDeadline.Load().(time.Time); ok && !d.IsZero() {
timer = time.NewTimer(time.Until(d))
defer timer.Stop()
deadline = timer.C
}

select {
case <-s.chReadEvent:
if timer != nil {
timer.Stop()
}
continue
case <-s.chFinEvent:
return 0, errors.WithStack(io.EOF)
case <-s.sess.chSocketReadError:
Expand Down

0 comments on commit 67e00e8

Please sign in to comment.