summaryrefslogtreecommitdiff
path: root/pkg/bindings/connection.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-08-25 14:42:12 -0400
committerGitHub <noreply@github.com>2021-08-25 14:42:12 -0400
commit49cfed756f5dfb6d9267eb29d31f651578c9037c (patch)
tree677b6acfee4b6fddc1b08d8181ce3552a5ccab68 /pkg/bindings/connection.go
parentfefa0b32c74fc5d394a0e2bd5b4564bedb3ed15d (diff)
parent1dc6d14735eef1e51368103aefba3d7c704dcfe3 (diff)
downloadpodman-49cfed756f5dfb6d9267eb29d31f651578c9037c.tar.gz
podman-49cfed756f5dfb6d9267eb29d31f651578c9037c.tar.bz2
podman-49cfed756f5dfb6d9267eb29d31f651578c9037c.zip
Merge pull request #11103 from jwhonce/wip/bindings
Fix file descriptor leaks in bindings and add test
Diffstat (limited to 'pkg/bindings/connection.go')
-rw-r--r--pkg/bindings/connection.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index cd118cbb2..4127ad2f0 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -56,7 +56,7 @@ func NewConnection(ctx context.Context, uri string) (context.Context, error) {
return NewConnectionWithIdentity(ctx, uri, "")
}
-// NewConnection takes a URI as a string and returns a context with the
+// NewConnectionWithIdentity takes a URI as a string and returns a context with the
// Connection embedded as a value. This context needs to be passed to each
// endpoint to work correctly.
//
@@ -149,6 +149,7 @@ func pingNewConnection(ctx context.Context) error {
if err != nil {
return err
}
+ defer response.Body.Close()
if response.StatusCode == http.StatusOK {
versionHdr := response.Header.Get("Libpod-API-Version")
@@ -338,7 +339,7 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string,
req.Header.Set(key, val)
}
// Give the Do three chances in the case of a comm/service hiccup
- for i := 0; i < 3; i++ {
+ for i := 1; i <= 3; i++ {
response, err = c.Client.Do(req) // nolint
if err == nil {
break
@@ -358,7 +359,7 @@ func FiltersToString(filters map[string][]string) (string, error) {
return jsoniter.MarshalToString(lowerCaseKeys)
}
-// IsInformation returns true if the response code is 1xx
+// IsInformational returns true if the response code is 1xx
func (h *APIResponse) IsInformational() bool {
return h.Response.StatusCode/100 == 1
}