Exit syslog acquis only after server is dead (#1288)
This commit is contained in:
parent
a300d5818f
commit
c3dbe0080c
|
@ -61,7 +61,7 @@ func (s *SyslogServer) StartServer() *tomb.Tomb {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-t.Dying():
|
case <-t.Dying():
|
||||||
s.Logger.Info("syslog server tomb is dying")
|
s.Logger.Info("Syslog server tomb is dying")
|
||||||
err := s.KillServer()
|
err := s.KillServer()
|
||||||
return err
|
return err
|
||||||
default:
|
default:
|
||||||
|
@ -92,5 +92,6 @@ func (s *SyslogServer) KillServer() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not close UDP connection")
|
return errors.Wrap(err, "could not close UDP connection")
|
||||||
}
|
}
|
||||||
|
close(s.channel)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,15 +180,15 @@ func (s *SyslogSource) buildLogFromSyslog(ts *time.Time, hostname *string,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyslogSource) handleSyslogMsg(out chan types.Event, t *tomb.Tomb, c chan syslogserver.SyslogMessage) error {
|
func (s *SyslogSource) handleSyslogMsg(out chan types.Event, t *tomb.Tomb, c chan syslogserver.SyslogMessage) error {
|
||||||
|
killed := false
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-t.Dying():
|
case <-t.Dying():
|
||||||
s.logger.Info("Syslog datasource is dying")
|
if !killed {
|
||||||
s.serverTomb.Kill(nil)
|
s.logger.Info("Syslog datasource is dying")
|
||||||
return s.serverTomb.Wait()
|
s.serverTomb.Kill(nil)
|
||||||
case <-s.serverTomb.Dying():
|
killed = true
|
||||||
s.logger.Info("Syslog server is dying, exiting")
|
}
|
||||||
return nil
|
|
||||||
case <-s.serverTomb.Dead():
|
case <-s.serverTomb.Dead():
|
||||||
s.logger.Info("Syslog server has exited")
|
s.logger.Info("Syslog server has exited")
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue