Skip to content
Snippets Groups Projects
Commit 8e7284de authored by HUANG Wei's avatar HUANG Wei Committed by Cameron Sparr
Browse files

fixup! Close the UDP connection in Stop() of statsd input plugin.

parent b2d38cd3
No related branches found
No related tags found
No related merge requests found
...@@ -66,7 +66,7 @@ type Statsd struct { ...@@ -66,7 +66,7 @@ type Statsd struct {
// bucket -> influx templates // bucket -> influx templates
Templates []string Templates []string
listener *net.UDPConn listener *net.UDPConn
} }
func NewStatsd() *Statsd { func NewStatsd() *Statsd {
...@@ -248,7 +248,7 @@ func (s *Statsd) Start(_ telegraf.Accumulator) error { ...@@ -248,7 +248,7 @@ func (s *Statsd) Start(_ telegraf.Accumulator) error {
// udpListen starts listening for udp packets on the configured port. // udpListen starts listening for udp packets on the configured port.
func (s *Statsd) udpListen() error { func (s *Statsd) udpListen() error {
var err error var err error
address, _ := net.ResolveUDPAddr("udp", s.ServiceAddress) address, _ := net.ResolveUDPAddr("udp", s.ServiceAddress)
s.listener, err = net.ListenUDP("udp", address) s.listener, err = net.ListenUDP("udp", address)
if err != nil { if err != nil {
...@@ -266,7 +266,7 @@ func (s *Statsd) udpListen() error { ...@@ -266,7 +266,7 @@ func (s *Statsd) udpListen() error {
n, _, err := s.listener.ReadFromUDP(buf) n, _, err := s.listener.ReadFromUDP(buf)
if err != nil { if err != nil {
log.Printf("ERROR READ: %s\n", err.Error()) log.Printf("ERROR READ: %s\n", err.Error())
continue continue
} }
select { select {
...@@ -561,7 +561,7 @@ func (s *Statsd) Stop() { ...@@ -561,7 +561,7 @@ func (s *Statsd) Stop() {
s.Lock() s.Lock()
defer s.Unlock() defer s.Unlock()
log.Println("Stopping the statsd service") log.Println("Stopping the statsd service")
s.listener.Close() s.listener.Close()
close(s.done) close(s.done)
close(s.in) close(s.in)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment