Discount dial errors that won't affect connection tracking
This will reduce pressure on the conntrack instance.
This commit is contained in:
parent
d9e1ebde70
commit
d9fe3f50d3
10
client.go
10
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")
|
||||
|
|
Loading…
Reference in New Issue