altcp: priority-based pcb/conn allocation required

altcp_tcp_new_ip_type: allocate the tcp pcb first to invoke the
priority handling code if we're out of pcbs
This commit is contained in:
goldsimon 2018-02-04 14:00:23 +01:00
parent f9bc3cae5d
commit 2a4dd0dc7b

View File

@ -185,18 +185,20 @@ altcp_tcp_setup(struct altcp_pcb *conn, struct tcp_pcb *tpcb)
struct altcp_pcb *
altcp_tcp_new_ip_type(u8_t ip_type)
{
struct altcp_pcb *ret = altcp_alloc();
if (ret != NULL) {
/* Allocate the tcp pcb first to invoke the priority handling code
if we're out of pcbs */
struct tcp_pcb *tpcb = tcp_new_ip_type(ip_type);
if (tpcb != NULL) {
struct altcp_pcb *ret = altcp_alloc();
if (ret != NULL) {
altcp_tcp_setup(ret, tpcb);
} else {
/* tcp_pcb allocation failed -> free the altcp_pcb too */
altcp_free(ret);
ret = NULL;
}
}
return ret;
} else {
/* altcp_pcb allocation failed -> free the tcp_pcb too */
tcp_close(tpcb);
}
}
return NULL;
}
struct altcp_pcb *