From 2102e0b8cbc8c01bef296a579b9f1f50bc3b9a5d Mon Sep 17 00:00:00 2001 From: Termina1 Date: Fri, 22 Nov 2024 12:15:20 +0530 Subject: [PATCH] fix stalling db closing in case there is exp backoff for connectin active --- protocol/net.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protocol/net.go b/protocol/net.go index ac0ecb4..73c5cbb 100644 --- a/protocol/net.go +++ b/protocol/net.go @@ -236,7 +236,11 @@ func (n *Net) KeepConnecting(ctx context.Context, name string, addrs []string) { if err != nil { n.log.Error("net: couldn't connect", "name", name, "err", err) - time.Sleep(connBackoff) + select { + case <-time.After(connBackoff): + case <-ctx.Done(): + break + } connBackoff = min(MAX_RETRY_PERIOD, connBackoff*2) continue