Skip to content

Commit 88ca8fa

Browse files
committed
close failed connections (#6898)
Signed-off-by: abhishek818 <[email protected]>
1 parent 6723599 commit 88ca8fa

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

services/auth/source/ldap/source_search.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func dial(source *Source) (*ldap.Conn, error) {
129129
conn, err := ldap.DialTLS("tcp", net.JoinHostPort(host, strconv.Itoa(source.Port)), tlsConfig)
130130
if err != nil {
131131
// Connection failed, try again with the next host.
132+
conn.Close()
132133
log.Trace("error during Dial for host %s: %w", host, err)
133134
continue
134135
}
@@ -139,6 +140,7 @@ func dial(source *Source) (*ldap.Conn, error) {
139140

140141
conn, err := ldap.Dial("tcp", net.JoinHostPort(host, strconv.Itoa(source.Port)))
141142
if err != nil {
143+
conn.Close()
142144
log.Trace("error during Dial for host %s: %w", host, err)
143145
continue
144146
}

0 commit comments

Comments
 (0)