Skip to content
Snippets Groups Projects
Commit 7f46aafc authored by Arkady Emelyanov's avatar Arkady Emelyanov Committed by Daniel Nelson
Browse files

Fix waitgroup deadlock if url is incorrect in apache input (#4176)

parent 3072b5a4
No related branches found
No related tags found
No related merge requests found
...@@ -57,6 +57,8 @@ func (n *Apache) Description() string { ...@@ -57,6 +57,8 @@ func (n *Apache) Description() string {
} }
func (n *Apache) Gather(acc telegraf.Accumulator) error { func (n *Apache) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
if len(n.Urls) == 0 { if len(n.Urls) == 0 {
n.Urls = []string{"http://localhost/server-status?auto"} n.Urls = []string{"http://localhost/server-status?auto"}
} }
...@@ -72,8 +74,6 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error { ...@@ -72,8 +74,6 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
n.client = client n.client = client
} }
var wg sync.WaitGroup
wg.Add(len(n.Urls))
for _, u := range n.Urls { for _, u := range n.Urls {
addr, err := url.Parse(u) addr, err := url.Parse(u)
if err != nil { if err != nil {
...@@ -81,6 +81,7 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error { ...@@ -81,6 +81,7 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
continue continue
} }
wg.Add(1)
go func(addr *url.URL) { go func(addr *url.URL) {
defer wg.Done() defer wg.Done()
acc.AddError(n.gatherUrl(addr, acc)) acc.AddError(n.gatherUrl(addr, acc))
......
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