From 8a046387496c688a1314d8d9486a8d7dea1afae9 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 3 Oct 2023 15:07:07 +0300 Subject: [PATCH] [#171] pool: Close only dialed connections To avoid panics during close operation, close only dialed connections. Signed-off-by: Alex Vanin --- pool/pool.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pool/pool.go b/pool/pool.go index 4d3cbf0..669970f 100644 --- a/pool/pool.go +++ b/pool/pool.go @@ -86,6 +86,8 @@ type client interface { type clientStatus interface { // isHealthy checks if the connection can handle requests. isHealthy() bool + // isDialed checks if the connection was created. + isDialed() bool // setUnhealthy marks client as unhealthy. setUnhealthy() // address return address of endpoint. @@ -2809,7 +2811,9 @@ func (p *Pool) Close() { // close all clients for _, pools := range p.innerPools { for _, cli := range pools.clients { - _ = cli.close() + if cli.isDialed() { + _ = cli.close() + } } } }