Skip to content

Commit

Permalink
Fix waitgroup deadlock if url is incorrect in apache input (#4176)
Browse files Browse the repository at this point in the history
(cherry picked from commit 7f46aaf)
arkady-emelyanov authored and danielnelson committed May 21, 2018

Verified

This commit was signed with the committer’s verified signature.
1 parent 066e048 commit e106bac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/inputs/apache/apache.go
Original file line number Diff line number Diff line change
@@ -63,6 +63,8 @@ func (n *Apache) Description() string {
}

func (n *Apache) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup

if len(n.Urls) == 0 {
n.Urls = []string{"http://localhost/server-status?auto"}
}
@@ -78,15 +80,14 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
n.client = client
}

var wg sync.WaitGroup
wg.Add(len(n.Urls))
for _, u := range n.Urls {
addr, err := url.Parse(u)
if err != nil {
acc.AddError(fmt.Errorf("Unable to parse address '%s': %s", u, err))
continue
}

wg.Add(1)
go func(addr *url.URL) {
defer wg.Done()
acc.AddError(n.gatherUrl(addr, acc))

0 comments on commit e106bac

Please sign in to comment.