mirror of
https://github.com/Icinga/icingabeat.git
synced 2025-07-28 08:14:02 +02:00
Close connectionts properly to prevent piling
This commit is contained in:
parent
55cd46c738
commit
fd5d3e93b3
@ -160,6 +160,8 @@ func (es *Eventstream) Run() error {
|
||||
logp.Err("Error connecting to API: %v", responseErr)
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
select {
|
||||
case <-es.done:
|
||||
return nil
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/elastic/beats/libbeat/logp"
|
||||
)
|
||||
@ -12,6 +13,8 @@ import (
|
||||
func requestURL(bt *Icingabeat, method string, URL *url.URL) (*http.Response, error) {
|
||||
transport := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: bt.config.SkipSSLVerify},
|
||||
MaxIdleConns: 10,
|
||||
IdleConnTimeout: 30 * time.Second,
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
@ -37,6 +40,7 @@ func requestURL(bt *Icingabeat, method string, URL *url.URL) (*http.Response, er
|
||||
switch response.StatusCode {
|
||||
case 401:
|
||||
err = errors.New("Authentication failed for user " + bt.config.User)
|
||||
defer response.Body.Close()
|
||||
}
|
||||
|
||||
return response, err
|
||||
|
@ -128,6 +128,8 @@ func (sp *Statuspoller) Run() error {
|
||||
logp.Err("Error connecting to API: %v", responseErr)
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
select {
|
||||
case <-sp.done:
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user