From 5bdec118ab9c7c37efea38f3e960da9c91058169 Mon Sep 17 00:00:00 2001 From: abhishek818 Date: Tue, 23 Jul 2024 03:36:11 +0530 Subject: [PATCH] close failed connections (#6898) Signed-off-by: abhishek818 --- services/auth/source/ldap/source_search.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/auth/source/ldap/source_search.go b/services/auth/source/ldap/source_search.go index e785f3953ebc3..ad5ebe365c680 100644 --- a/services/auth/source/ldap/source_search.go +++ b/services/auth/source/ldap/source_search.go @@ -129,6 +129,7 @@ func dial(source *Source) (*ldap.Conn, error) { conn, err := ldap.DialTLS("tcp", net.JoinHostPort(host, strconv.Itoa(source.Port)), tlsConfig) if err != nil { // Connection failed, try again with the next host. + conn.Close() log.Trace("error during Dial for host %s: %w", host, err) continue } @@ -139,6 +140,7 @@ func dial(source *Source) (*ldap.Conn, error) { conn, err := ldap.Dial("tcp", net.JoinHostPort(host, strconv.Itoa(source.Port))) if err != nil { + conn.Close() log.Trace("error during Dial for host %s: %w", host, err) continue }