diff --git a/revid/senders.go b/revid/senders.go index 5f290fa2..a4aec8b3 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -322,7 +322,9 @@ func (s *rtmpSender) output() { } } _, err := s.conn.Write(chunk.Bytes()) - if err != nil { + switch err { + case nil, rtmp.ErrInvalidFlvTag: + default: s.log(logger.Warning, pkg+"rtmpSender: send error, restarting...", "error", err.Error()) err = s.restart() if err != nil { @@ -347,7 +349,7 @@ func (s *rtmpSender) Write(d []byte) (int, error) { } func (s *rtmpSender) restart() error { - s.Close() + s.close() var err error for n := 0; n < s.retries; n++ { s.conn, err = rtmp.Dial(s.url, s.timeout, s.log) @@ -363,6 +365,14 @@ func (s *rtmpSender) restart() error { } func (s *rtmpSender) Close() error { + if s.quit != nil { + close(s.quit) + } + s.wg.Wait() + return s.close() +} + +func (s *rtmpSender) close() error { if s.conn == nil { return nil }