Skip to content

Commit

Permalink
upstream: close plain connections
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jun 8, 2023
1 parent 4162e21 commit 6687dac
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions upstream/upstream_plain.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ func (p *plainDNS) dialExchange(
if err != nil {
return nil, fmt.Errorf("dialing %s over %s: %w", p.addr.Host, network, err)
}
defer func(c net.Conn) { err = errors.WithDeferred(err, c.Close()) }(conn.Conn)

resp, _, err = client.ExchangeWithConn(req, conn)
if isExpectedConnErr(err) {
conn.Conn, err = dial(ctx, string(network), "")
if err != nil {
return nil, fmt.Errorf("dialing %s over %s again: %w", p.addr.Host, network, err)
}
defer func(c net.Conn) { err = errors.WithDeferred(err, c.Close()) }(conn.Conn)

resp, _, err = client.ExchangeWithConn(req, conn)
}
Expand Down

0 comments on commit 6687dac

Please sign in to comment.