Fix waitgroup deadlock if url is incorrect in apache input (#4176)
This commit is contained in:
parent
3072b5a493
commit
7f46aafcd6
|
@ -57,6 +57,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"}
|
||||
}
|
||||
|
@ -72,8 +74,6 @@ 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 {
|
||||
|
@ -81,6 +81,7 @@ func (n *Apache) Gather(acc telegraf.Accumulator) error {
|
|||
continue
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func(addr *url.URL) {
|
||||
defer wg.Done()
|
||||
acc.AddError(n.gatherUrl(addr, acc))
|
||||
|
|
Loading…
Reference in New Issue