Compare commits

..

3 commits

Author SHA1 Message Date
12ef42f496 [#276] Merge repo with frostfs-api-go
Some checks failed
DCO / DCO (pull_request) Successful in 1m23s
Tests and linters / Tests (pull_request) Failing after 1m23s
Tests and linters / Lint (pull_request) Successful in 1m33s
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-12 12:15:53 +03:00
d7872061f8
[#284] go.mod: Update api-go
All checks were successful
DCO / DCO (pull_request) Successful in 44s
Tests and linters / Tests (pull_request) Successful in 1m10s
Tests and linters / Lint (pull_request) Successful in 1m58s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-10-11 15:17:23 +03:00
99c5c58365
[#282] client: Close connection on non-nil error in Dial
All checks were successful
DCO / DCO (pull_request) Successful in 50s
Tests and linters / Tests (pull_request) Successful in 1m25s
Tests and linters / Lint (pull_request) Successful in 2m3s
A particular status code does not imply that a connection has not been
established. However, `Dial()` requires user to call `Close()` only if
the error was nil. Thus, it is `Dial()` responsibility to close
everything if it returns an error.

Introduced after the gRPC update in #270 (6009d089fc).

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-10-10 14:03:44 +03:00

View file

@ -106,16 +106,21 @@ func (c *Client) Dial(ctx context.Context, prm PrmDial) error {
client.WithContext(ctx),
)
if err != nil {
var ctxErr error
// return context errors since they signal about dial problem
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return err
ctxErr = err
} else if st, ok := status.FromError(err); ok && st.Code() == codes.Canceled {
ctxErr = context.Canceled
} else if ok && st.Code() == codes.DeadlineExceeded {
ctxErr = context.DeadlineExceeded
}
st, ok := status.FromError(err)
if ok && st.Code() == codes.Canceled {
return context.Canceled
if ctxErr != nil {
if conn := c.c.Conn(); conn != nil {
_ = conn.Close()
}
if ok && st.Code() == codes.DeadlineExceeded {
return context.DeadlineExceeded
return ctxErr
}
}