mirror of https://bitbucket.org/ausocean/av.git
revid: fixed multiSender sending and handling of send fails
This commit is contained in:
parent
85401c8df4
commit
48c7a1f21d
|
@ -70,28 +70,36 @@ func newMultiSender(owner *Revid, senders []loadSender) *multiSender {
|
||||||
func (s *multiSender) Write(d []byte) (int, error) {
|
func (s *multiSender) Write(d []byte) (int, error) {
|
||||||
for i, sender := range s.senders {
|
for i, sender := range s.senders {
|
||||||
sender.load(d)
|
sender.load(d)
|
||||||
s.owner.config.Logger.Log(logger.Debug, "sending to output", "output", i)
|
|
||||||
err := sender.send()
|
err := sender.send()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !s.owner.IsRunning() {
|
s.owner.config.Logger.Log(logger.Warning, "send failed", "output", i, "error", err)
|
||||||
return 0, err
|
s.handleFail(sender, err)
|
||||||
}
|
for s.owner.config.SendRetry {
|
||||||
if s.owner.config.SendRetry {
|
if !s.owner.IsRunning() {
|
||||||
for err != nil {
|
sender.release()
|
||||||
s.owner.config.Logger.Log(logger.Warning, "send failed", "output", i, "error", err)
|
return 0, err
|
||||||
err = sender.handleSendFail(err)
|
|
||||||
if err != nil {
|
|
||||||
s.owner.config.Logger.Log(logger.Warning, "could not currenty handle send fail", "output", i, "error", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
err = sender.send()
|
|
||||||
}
|
}
|
||||||
|
err = sender.send()
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
s.handleFail(sender, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sender.release()
|
||||||
}
|
}
|
||||||
return len(d), nil
|
return len(d), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleFail calls the passed sender's handleSendFail method and then logs
|
||||||
|
// error if this was not successful.
|
||||||
|
func (s *multiSender) handleFail(sender loadSender, e error) {
|
||||||
|
err := sender.handleSendFail(e)
|
||||||
|
if err != nil {
|
||||||
|
s.owner.config.Logger.Log(logger.Warning, "could not currenty handle send fail", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// minimalHttpSender implements Sender for posting HTTP to netreceiver or vidgrind.
|
// minimalHttpSender implements Sender for posting HTTP to netreceiver or vidgrind.
|
||||||
type minimalHttpSender struct {
|
type minimalHttpSender struct {
|
||||||
client *netsender.Sender
|
client *netsender.Sender
|
||||||
|
|
Loading…
Reference in New Issue