Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Oct 27, 2024
1 parent f7d704f commit 3357c09
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/net/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func NewDialer(opts ...DialerOption) (der Dialer, err error) {

netpoll.SetLoadBalance(netpoll.RoundRobin)
d.npDialer = netpoll.NewDialer()

d.dialer = d.dial
if d.enableDNSCache {
if d.dnsRefreshDuration > d.dnsCacheExpiration {
Expand Down Expand Up @@ -330,7 +329,14 @@ func (d *dialer) dial(ctx context.Context, network, addr string) (conn Conn, err
} else {
conn, err = d.npDialer.DialConnection(network, addr, d.der.Timeout)
if err != nil {
conn, err = d.der.DialContext(ctx, network, addr)
if conn != nil {
err = errors.Join(err, conn.Close())
}
var ierr error
conn, ierr = d.der.DialContext(ctx, network, addr)
if ierr != nil {
err = errors.Join(err, ierr)
}
}
}
return err
Expand Down

0 comments on commit 3357c09

Please sign in to comment.