diff --git a/CHANGELOG b/CHANGELOG index 3671ca71..a7321b25 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -46,6 +46,10 @@ HISTORY ++ Bugfixes: + 2009-11-22: Simon Goldschmidt (suggested by Bill Auerbach) + * tcp.c: tcp_alloc: prevent increasing stats.err for MEMP_TCP_PCB when + reusing time-wait pcb + 2009-11-20: Simon Goldschmidt (patch by Albert Bartel) * sockets.c: Fixed bug #28062: Data received directly after accepting does not wake up select diff --git a/src/core/tcp.c b/src/core/tcp.c index fc5c6624..29cdf185 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -50,6 +50,7 @@ #include "lwip/snmp.h" #include "lwip/tcp.h" #include "lwip/debug.h" +#include "lwip/stats.h" #include @@ -1015,9 +1016,18 @@ tcp_alloc(u8_t prio) pcb = memp_malloc(MEMP_TCP_PCB); if (pcb == NULL) { /* Try killing active connections with lower priority than the new one. */ + LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing connection with prio lower than %d\n", prio)); tcp_kill_prio(prio); /* Try to allocate a tcp_pcb again. */ pcb = memp_malloc(MEMP_TCP_PCB); + if (pcb != NULL) { + /* adjust err stats: memp_malloc failed twice before */ + MEMP_STATS_DEC(err, MEMP_TCP_PCB); + } + } + if (pcb != NULL) { + /* adjust err stats: timewait PCB was freed above */ + MEMP_STATS_DEC(err, MEMP_TCP_PCB); } } if (pcb != NULL) {