Fix panics when collectd fails to start

If collectd fails to start, it can panic when close is called because
some variables have not be initialized yet.
pull/3193/head
Jason Wilder 2015-06-29 22:09:47 -06:00
parent 258f0fcdfa
commit 87c962d62d
1 changed files with 9 additions and 3 deletions

View File

@ -118,9 +118,15 @@ func (s *Service) Open() error {
// Close stops the service.
func (s *Service) Close() error {
// Close the connection, and wait for the goroutine to exit.
if s.stop != nil {
close(s.stop)
}
if s.ln != nil {
s.ln.Close()
}
if s.batcher != nil {
s.batcher.Stop()
}
s.wg.Wait()
// Release all remaining resources.