diff --git a/libports/include/lwip/lwipopts.h b/libports/include/lwip/lwipopts.h index d4dea2e54d..c3af641afe 100644 --- a/libports/include/lwip/lwipopts.h +++ b/libports/include/lwip/lwipopts.h @@ -49,6 +49,19 @@ #define TCP_MSS 1460 #define TCP_SND_BUF (2 * TCP_MSS) +/* + * We reduce the maximum segment lifetime from one minute to one second to + * avoid queuing up PCBs in TIME-WAIT state. This is the state, PCBs end up + * after closing a TCP connection socket at the server side. The number of PCBs + * in this state is apparently not limited by the value of 'MEMP_NUM_TCP_PCB'. + * One allocation costs around 160 bytes. If clients connect to the server at a + * high rate, those allocations accumulate quickly and thereby may exhaust the + * memory of the server. By reducing the segment lifetime, PCBs in TIME-WAIT + * state are cleaned up from the 'tcp_tw_pcbs' queue in a more timely fashion + * (by 'tcp_slowtmr()'). + */ +#define TCP_MSL 1000UL + #define MEMP_NUM_SYS_TIMEOUT 8 #define MEMP_NUM_TCP_PCB 64 #define MEMP_NUM_NETCONN (MEMP_NUM_TCP_PCB + MEMP_NUM_UDP_PCB + MEMP_NUM_RAW_PCB + MEMP_NUM_TCP_PCB_LISTEN - 1)