From 9a52f19e3d3c4d2051ea95c4690548ad8b1f295d Mon Sep 17 00:00:00 2001 From: Saxon Date: Wed, 10 Apr 2019 12:19:28 +0930 Subject: [PATCH] revid: fixed mtsSender's output routine's logic --- revid/senders.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/revid/senders.go b/revid/senders.go index 2b65b0e9..d50fc7d8 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -183,7 +183,6 @@ func newMtsSender(dst io.WriteCloser, log func(lvl int8, msg string, args ...int // output starts an mtsSender's data handling routine. func (s *mtsSender) output() { var chunk *ring.Chunk -loop: for { select { case <-s.quit: @@ -197,6 +196,7 @@ loop: chunk, err = s.ringBuf.Next(readTimeout) switch err { case nil: + continue case ring.ErrTimeout: s.log(logger.Debug, pkg+"mtsSender: ring buffer read timeout") continue @@ -204,24 +204,22 @@ loop: s.log(logger.Error, pkg+"mtsSender: unexpected error", "error", err.Error()) fallthrough case io.EOF: - goto loop - } - // If chunk is not nil, then we need to try sending it off. - } else { - err := s.repairer.Repair(chunk.Bytes()) - if err != nil { - chunk.Close() - chunk = nil - continue - } - _, err = s.dst.Write(chunk.Bytes()) - if err != nil { - s.repairer.Failed() continue } + } + err := s.repairer.Repair(chunk.Bytes()) + if err != nil { chunk.Close() chunk = nil + continue } + _, err = s.dst.Write(chunk.Bytes()) + if err != nil { + s.repairer.Failed() + continue + } + chunk.Close() + chunk = nil } } }