Skip to content

Commit

Permalink
haproxy input: fix potential race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Jun 2, 2016
1 parent 8173338 commit 6754578
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plugins/inputs/haproxy/haproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
"io"
"log"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -113,20 +114,18 @@ func (g *haproxy) Gather(acc telegraf.Accumulator) error {
}

var wg sync.WaitGroup

var outerr error

for _, serv := range g.Servers {
for _, server := range g.Servers {
wg.Add(1)
go func(serv string) {
defer wg.Done()
outerr = g.gatherServer(serv, acc)
}(serv)
if err := g.gatherServer(serv, acc); err != nil {
log.Printf("HAProxy error gathering server: %s, %s", serv, err)
}
}(server)
}

wg.Wait()

return outerr
return nil
}

func (g *haproxy) gatherServerSocket(addr string, acc telegraf.Accumulator) error {
Expand Down

0 comments on commit 6754578

Please sign in to comment.