mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
httpd: reap idle TCP connections (#390)
* uip: time out an ESTABLISHED connection whose peer went silent uIP has no keepalive and no idle timeout for an ESTABLISHED connection, so a peer that vanishes without FIN or RST holds it open forever. A crashed client does it, and so does a SYN caught while the switch is still booting. With UIP_CONF_MAX_CONNECTIONS = 1 that wedges the single slot: the web UI stops answering, port 80 no longer even SYN-ACKs, and only a power cycle recovers it. Every other TCP state already has an exit path (UIP_MAXRTX, UIP_TIME_WAIT_TIMEOUT); idle ESTABLISHED was the one hole. Close it inside uIP rather than in httpd, so any future TCP service is covered too. The retransmission timer is unused while nothing is in flight, so the idle count lives in it: a 1 Hz strobe derived from the uip_periodic() rate ages it, any arriving segment clears it, and past the limit the connection is aborted through the same path as UIP_MAXRTX. Two new options in uipopt.h, default off; this project enables 30 s. httpd also joins uip_timedout() to its cleanup: it only handled closed and aborted, so both this timeout and the existing UIP_MAXRTX one would have left the transfer state stuck on a dead connection. * uip: keep the tuning values out of the prose The comment named the timeout and the tick rate, which go stale the moment either constant is edited. It now says why an idle connection is aged out and leaves the numbers to the defines under it.
This commit is contained in:
4 files changed
+88
-1
No files matched your search
@@ -96,6 +96,21 @@ typedef unsigned short uip_stats_t;
|
||||
*/
|
||||
#define UIP_CONF_MAX_CONNECTIONS 1
|
||||
|
||||
/**
|
||||
* This httpd closes after every response, so an ESTABLISHED connection
|
||||
* that stays idle is a peer that died or never sent its request. With a
|
||||
* single connection slot it would hold the web UI until the next power
|
||||
* cycle, so it is aged out instead.
|
||||
*
|
||||
* uip_periodic() runs from idle() once per system tick; interrupt
|
||||
* wake-ups only add sweeps, so the timeout can fire early but never
|
||||
* late.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_IDLE_PERIODS 200
|
||||
#define UIP_CONF_IDLE_TIMEOUT 30
|
||||
|
||||
/**
|
||||
* Maximum number of listening TCP ports. TODO: increase this!
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user