tcp_alloc: prevent increasing stats.err for MEMP_TCP_PCB when reusing time-wait pcb as suggested by Bill 4 months ago

This commit is contained in:
goldsimon 2009-11-22 17:52:48 +00:00
parent 10edf64873
commit 35d1c33e0a
2 changed files with 14 additions and 0 deletions

View File

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

View File

@ -50,6 +50,7 @@
#include "lwip/snmp.h"
#include "lwip/tcp.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include <string.h>
@ -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) {