Merge pull request #2937 from hashicorp/b-leak-plugin

Fix leaked plugin files for syslog server
This commit is contained in:
Alex Dadgar 2017-07-31 10:38:04 -07:00 committed by GitHub
commit 0a75fe53b6
1 changed files with 9 additions and 2 deletions

View File

@ -37,11 +37,17 @@ func (s *SyslogServer) Start() {
for {
select {
case <-s.doneCh:
s.listener.Close()
return
default:
connection, err := s.listener.Accept()
if err != nil {
s.doneLock.Lock()
done := s.done
s.doneLock.Unlock()
if done {
return
}
s.logger.Printf("[ERR] logcollector.server: error in accepting connection: %v", err)
continue
}
@ -74,11 +80,12 @@ func (s *SyslogServer) read(connection net.Conn) {
// Shutdown shutsdown the syslog server
func (s *SyslogServer) Shutdown() {
s.doneLock.Lock()
s.doneLock.Unlock()
defer s.doneLock.Unlock()
if !s.done {
close(s.doneCh)
close(s.messages)
s.done = true
s.listener.Close()
}
}