lwip: purge PCBs in time-wait state more quickly

Fixes #33.
This commit is contained in:
Norman Feske 2012-08-15 22:48:56 +02:00
parent 302e30662a
commit 24107d7a48

View File

@ -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)