From d9fe3f50d3f17e13bf037fcf0a212bdb769e13dd Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 28 Nov 2018 10:32:08 +1100 Subject: [PATCH] Discount dial errors that won't affect connection tracking This will reduce pressure on the conntrack instance. --- client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 1fa9c2bc..a1cea721 100644 --- a/client.go +++ b/client.go @@ -530,7 +530,11 @@ func (cl *Client) dialFirst(ctx context.Context, addr string) dialResult { countDialResult(err) dr := dialResult{c, network} if c == nil { - cte.Done() + if err != nil && forgettableDialError(err) { + cte.Forget() + } else { + cte.Done() + } } else { dr.Conn = closeWrapper{c, func() error { err := c.Close() @@ -567,6 +571,10 @@ func (cl *Client) dialFirst(ctx context.Context, addr string) dialResult { return res } +func forgettableDialError(err error) bool { + return strings.Contains(err.Error(), "no suitable address found") +} + func (cl *Client) noLongerHalfOpen(t *Torrent, addr string) { if _, ok := t.halfOpen[addr]; !ok { panic("invariant broken") -- 2.48.1