satellite/contact: fix connection leak in PingMe endpoint

Fixes connection leak in pingMe endpoint.
includes other minor fixes.

Change-Id: I7c61f620565f46dd113d21a772de7c439be550e3
This commit is contained in:
Clement Sam 2022-01-20 14:20:24 +00:00
parent 8b40a071a0
commit 2de6feefde

View File

@ -177,6 +177,9 @@ func (endpoint *Endpoint) PingMe(ctx context.Context, req *pb.PingMeRequest) (_
if err != nil {
return nil, endpoint.checkPingRPCErr(err, nodeURL)
}
defer func() { err = errs.Combine(err, client.Close()) }()
_, err = client.pingNode(ctx, &pb.ContactPingRequest{})
if err != nil {
return nil, endpoint.checkPingRPCErr(err, nodeURL)
@ -184,7 +187,7 @@ func (endpoint *Endpoint) PingMe(ctx context.Context, req *pb.PingMeRequest) (_
return &pb.PingMeResponse{}, nil
}
return nil, rpcstatus.Errorf(rpcstatus.InvalidArgument, errCheckInNetwork.New("invalid transport: %s", req.Transport).Error())
return nil, rpcstatus.Errorf(rpcstatus.InvalidArgument, "invalid transport: %v", req.Transport)
}
func (endpoint *Endpoint) checkPingRPCErr(err error, nodeURL storj.NodeURL) error {