This will reduce pressure on the conntrack instance.
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()
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")