From 7edbd3127577d5922ac6c9101160e4e7cf0c5782 Mon Sep 17 00:00:00 2001 From: Maddin-619 Date: Thu, 1 Jun 2023 11:32:32 +0200 Subject: [PATCH 1/3] setSession if activate failes to close it properly --- client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/client.go b/client.go index fc5f3e23..e2ef7c86 100644 --- a/client.go +++ b/client.go @@ -222,6 +222,7 @@ func (c *Client) Connect(ctx context.Context) error { } if err := c.ActivateSessionWithContext(ctx, s); err != nil { + c.setSession(s) c.CloseWithContext(ctx) stats.RecordError(err) From 096fb15f766320d26732b3de43d248036fb31697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Mon, 5 Jun 2023 10:39:08 +0200 Subject: [PATCH 2/3] make closing of session explicit --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index e2ef7c86..79dde71a 100644 --- a/client.go +++ b/client.go @@ -222,7 +222,7 @@ func (c *Client) Connect(ctx context.Context) error { } if err := c.ActivateSessionWithContext(ctx, s); err != nil { - c.setSession(s) + c.closeSession(ctx, s) // ignore error since we cannot handle it anyway c.CloseWithContext(ctx) stats.RecordError(err) From e7fe39b8135064bd06f7fbaacf8077306323769e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Schr=C3=B6der?= Date: Mon, 5 Jun 2023 10:39:30 +0200 Subject: [PATCH 3/3] Use WithContext method --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 79dde71a..c9440339 100644 --- a/client.go +++ b/client.go @@ -889,7 +889,7 @@ func (c *Client) ActivateSessionWithContext(ctx context.Context, s *Session) err // We decided not to check the error of CloseSession() since we // can't do much about it anyway and it creates a race in the // re-connection logic. - c.CloseSession() + c.CloseSessionWithContext(ctx) c.setSession(s) return nil