Merge pull request #2937 from hashicorp/b-leak-plugin
Fix leaked plugin files for syslog server
This commit is contained in:
commit
0a75fe53b6
|
@ -37,11 +37,17 @@ func (s *SyslogServer) Start() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.doneCh:
|
case <-s.doneCh:
|
||||||
s.listener.Close()
|
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
connection, err := s.listener.Accept()
|
connection, err := s.listener.Accept()
|
||||||
if err != nil {
|
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)
|
s.logger.Printf("[ERR] logcollector.server: error in accepting connection: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -74,11 +80,12 @@ func (s *SyslogServer) read(connection net.Conn) {
|
||||||
// Shutdown shutsdown the syslog server
|
// Shutdown shutsdown the syslog server
|
||||||
func (s *SyslogServer) Shutdown() {
|
func (s *SyslogServer) Shutdown() {
|
||||||
s.doneLock.Lock()
|
s.doneLock.Lock()
|
||||||
s.doneLock.Unlock()
|
defer s.doneLock.Unlock()
|
||||||
|
|
||||||
if !s.done {
|
if !s.done {
|
||||||
close(s.doneCh)
|
close(s.doneCh)
|
||||||
close(s.messages)
|
close(s.messages)
|
||||||
s.done = true
|
s.done = true
|
||||||
|
s.listener.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue