Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input plugin for DC/OS #3519

Merged
merged 15 commits into from
Nov 29, 2017
Prev Previous commit
Next Next commit
Release semaphore after closing response body
danielnelson committed Nov 29, 2017

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 8a190a08f62ca37174fb8835704b2baafd95dfd4
12 changes: 6 additions & 6 deletions plugins/inputs/dcos/client.go
Original file line number Diff line number Diff line change
@@ -289,28 +289,28 @@ func (c *client) doGet(ctx context.Context, url string, v interface{}) error {
<-c.semaphore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly add this to the defer above

return err
}
defer resp.Body.Close()
defer func() {
resp.Body.Close()
<-c.semaphore
}()

// Clear invalid token if unauthorized
if resp.StatusCode == 401 {
if resp.StatusCode == http.StatusUnauthorized {
c.token = ""
}

if resp.StatusCode < 200 || resp.StatusCode >= 300 {
<-c.semaphore
return &APIError{
StatusCode: resp.StatusCode,
Title: resp.Status,
}
}

if resp.StatusCode == 204 {
<-c.semaphore
if resp.StatusCode == http.StatusNoContent {
return nil
}

err = json.NewDecoder(resp.Body).Decode(v)
<-c.semaphore
return err
}