mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-26 03:16:18 +00:00
task #14600: tcp_alloc(): kill TF_CLOSEPEND connections before other ESTABLISHED
This commit is contained in:
parent
5dc3072af8
commit
444dfeada8
@ -1719,6 +1719,28 @@ tcp_kill_timewait(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called when allocating a pcb fails.
|
||||||
|
* In this case, we want to handle all pcbs that want to close first: if we can
|
||||||
|
* now send the FIN (which failed before), the pcb might be in a state that is
|
||||||
|
* OK for us to now free it.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
tcp_handle_closepend(void)
|
||||||
|
{
|
||||||
|
struct tcp_pcb *pcb = tcp_active_pcbs;
|
||||||
|
|
||||||
|
while (pcb != NULL) {
|
||||||
|
struct tcp_pcb *next = pcb->next;
|
||||||
|
/* send pending FIN */
|
||||||
|
if (pcb->flags & TF_CLOSEPEND) {
|
||||||
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: pending FIN\n"));
|
||||||
|
tcp_clear_flags(pcb, TF_CLOSEPEND);
|
||||||
|
tcp_close_shutdown_fin(pcb);
|
||||||
|
}
|
||||||
|
pcb = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate a new tcp_pcb structure.
|
* Allocate a new tcp_pcb structure.
|
||||||
*
|
*
|
||||||
@ -1732,6 +1754,9 @@ tcp_alloc(u8_t prio)
|
|||||||
|
|
||||||
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
|
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
|
||||||
if (pcb == NULL) {
|
if (pcb == NULL) {
|
||||||
|
/* Try to send FIN for all pcbs stuck in TF_CLOSEPEND first */
|
||||||
|
tcp_handle_closepend();
|
||||||
|
|
||||||
/* Try killing oldest connection in TIME-WAIT. */
|
/* Try killing oldest connection in TIME-WAIT. */
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n"));
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n"));
|
||||||
tcp_kill_timewait();
|
tcp_kill_timewait();
|
||||||
|
Loading…
Reference in New Issue
Block a user