job source: do not stop listener on accept() errors

refs #77
This commit is contained in:
Christian Schwarz 2018-08-25 13:00:51 +02:00
parent d677cde6d0
commit 51cfcfe79b

View File

@ -160,16 +160,11 @@ func (j *SourceJob) serve(ctx context.Context, task *Task) {
connChan := make(chan connChanMsg)
// Serve connections until interrupted or error
outer:
outer:
for {
go func() {
rwc, err := listener.Accept()
if err != nil {
connChan <- connChanMsg{rwc, err}
close(connChan)
return
}
connChan <- connChanMsg{rwc, err}
}()
@ -178,8 +173,8 @@ outer:
case rwcMsg := <-connChan:
if rwcMsg.err != nil {
task.Log().WithError(err).Error("error accepting connection")
break outer
task.Log().WithError(rwcMsg.err).Error("error accepting connection")
continue
}
j.handleConnection(rwcMsg.conn, task)
@ -187,11 +182,12 @@ outer:
case <-ctx.Done():
task.Log().WithError(ctx.Err()).Info("context")
break outer
}
}
task.Log().Info("closing listener")
task.Enter("close_listener")
defer task.Finish()
err = listener.Close()