Resto: enable TCP keepalive on accepted server connections
What
Enable SO_KEEPALIVE on connections accepted by the resto RPC server.
Why
The RPC server keeps accepted connections open between requests (HTTP keep-alive). If the remote peer disappears without closing the connection — common when a NAT or load balancer drops an idle flow without notifying either endpoint — the server cannot detect it, since it never writes on an idle connection. Such connections, and their file descriptors, are then retained until the process restarts. Long-lived, publicly reachable servers accumulate them over time.
SO_KEEPALIVE lets the kernel probe idle peers after net.ipv4.tcp_keepalive_time (2h by default; operators can lower it system-wide) and close connections whose peer is gone, releasing the resources.
Verification
On a node holding an idle keep-alive connection, ss -tno on the accepted socket shows a keepalive timer with this change and none without it.
Notes
- TCP only; domain sockets and vchan are unaffected.
- Reap latency follows the system keepalive settings. A configurable server-side idle timeout would complement this and is left as a follow-up.