A connection whose peer has gone away without closing it, or whose state
a NAT or firewall in between has dropped, is only noticed by the
kernel's default keep-alive schedule after more than two hours of
silence. fetchTimeout defaults to zero, and of the consumers in base
only fetch(1) sets it, so pkg(7) and bsdinstall wait that long
for a read that will never complete. An idle connection, such as the
FTP control connection during a long transfer, can also lose its NAT
state while nobody is reading from it.
Enable SO_KEEPALIVE in fetch_reopen(), which every connection goes
through, FTP data connections included, and send the first probe after
60 seconds of silence instead of net.inet.tcp.keepidle's two hours.
How often to probe and how many unanswered probes end the connection
are left to net.inet.tcp.keepintvl and keepcnt. With their defaults,
8 probes 75 seconds apart, a peer which stops responding entirely is
noticed after about 11 minutes, close to the 10 minutes of the curl
command's default, and the operation fails with FETCH_TIMEOUT.
A caller without fetchTimeout which used to ride out a network outage
of more than about 11 minutes now sees the transfer fail instead. A
server which is reachable but sends nothing is still only caught by
fetchTimeout.
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")