Skip to content

Commit

Permalink
Merge pull request #2937 from hashicorp/b-leak-plugin
Browse files Browse the repository at this point in the history
Fix leaked plugin files for syslog server
  • Loading branch information
dadgar committed Jul 31, 2017
2 parents 476f45b + 212fed6 commit 03f9c11
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/driver/logging/syslog_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
}
}

0 comments on commit 03f9c11

Please sign in to comment.