Merge pull request #729 from harshavardhana/pr_out_add_abbreviated_close_response_to_avoid_any_leaks

master
Harshavardhana 9 years ago
commit d7acf90b81
  1. 16
      pkg/controller/client.go

@ -26,6 +26,12 @@ import (
"github.com/minio/minio/pkg/server/rpc" "github.com/minio/minio/pkg/server/rpc"
) )
func closeResp(resp *http.Response) {
if resp != nil && resp.Body != nil {
resp.Body.Close()
}
}
// GetDisks get disks info of the server at given url // GetDisks get disks info of the server at given url
func GetDisks(url string) ([]byte, error) { func GetDisks(url string) ([]byte, error) {
op := RPCOps{ op := RPCOps{
@ -37,10 +43,10 @@ func GetDisks(url string) ([]byte, error) {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
resp, err := req.Do() resp, err := req.Do()
defer closeResp(resp)
if err != nil { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
defer resp.Body.Close()
var reply rpc.DiskInfoReply var reply rpc.DiskInfoReply
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil { if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
@ -59,10 +65,10 @@ func GetMemStats(url string) ([]byte, error) {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
resp, err := req.Do() resp, err := req.Do()
defer closeResp(resp)
if err != nil { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
defer resp.Body.Close()
var reply rpc.MemStatsReply var reply rpc.MemStatsReply
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil { if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
@ -81,10 +87,10 @@ func GetSysInfo(url string) ([]byte, error) {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
resp, err := req.Do() resp, err := req.Do()
defer closeResp(resp)
if err != nil { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
defer resp.Body.Close()
var reply rpc.SysInfoReply var reply rpc.SysInfoReply
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil { if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
@ -103,10 +109,10 @@ func GetAuthKeys(url string) ([]byte, error) {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
resp, err := req.Do() resp, err := req.Do()
defer closeResp(resp)
if err != nil { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
defer resp.Body.Close()
var reply rpc.AuthReply var reply rpc.AuthReply
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil { if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
@ -141,10 +147,10 @@ func SetDonut(url, hostname string, disks []string) error {
return iodine.New(err, nil) return iodine.New(err, nil)
} }
resp, err := req.Do() resp, err := req.Do()
defer closeResp(resp)
if err != nil { if err != nil {
return iodine.New(err, nil) return iodine.New(err, nil)
} }
defer resp.Body.Close()
var reply rpc.Reply var reply rpc.Reply
if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil { if err := jsonrpc.DecodeClientResponse(resp.Body, &reply); err != nil {
return iodine.New(err, nil) return iodine.New(err, nil)

Loading…
Cancel
Save