mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lwip: update according to review comments
1. Define memp_malloc/memp_free as static inline function 2. When TCP pcb is out of memory, try to kill PCB in FIN_WAIT_1 when necessary
This commit is contained in:
parent
b08113d2b4
commit
9cc9710a27
@ -1394,6 +1394,7 @@ typedef struct {
|
|||||||
u8_t closing;
|
u8_t closing;
|
||||||
u8_t fin_wait2;
|
u8_t fin_wait2;
|
||||||
u8_t last_ack;
|
u8_t last_ack;
|
||||||
|
u8_t fin_wait1;
|
||||||
u8_t listen;
|
u8_t listen;
|
||||||
u8_t bound;
|
u8_t bound;
|
||||||
u8_t total;
|
u8_t total;
|
||||||
@ -1422,6 +1423,8 @@ void tcp_pcb_num_cal(tcp_pcb_num_t *tcp_pcb_num)
|
|||||||
tcp_pcb_num->last_ack ++;
|
tcp_pcb_num->last_ack ++;
|
||||||
} else if (pcb->state == CLOSING) {
|
} else if (pcb->state == CLOSING) {
|
||||||
tcp_pcb_num->closing ++;
|
tcp_pcb_num->closing ++;
|
||||||
|
} else if (pcb->state == FIN_WAIT_1){
|
||||||
|
tcp_pcb_num->fin_wait1 ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1463,7 +1466,9 @@ tcp_alloc(u8_t prio)
|
|||||||
} else if (tcp_pcb_num.closing > 0){
|
} else if (tcp_pcb_num.closing > 0){
|
||||||
tcp_kill_state(CLOSING);
|
tcp_kill_state(CLOSING);
|
||||||
} else if (tcp_pcb_num.fin_wait2 > 0){
|
} else if (tcp_pcb_num.fin_wait2 > 0){
|
||||||
tcp_kill_state(FIN_WAIT_2);//TODO check whether we have issue here?????
|
tcp_kill_state(FIN_WAIT_2);
|
||||||
|
} else if (tcp_pcb_num.fin_wait1 > 0){
|
||||||
|
tcp_kill_state(FIN_WAIT_1);
|
||||||
} else {
|
} else {
|
||||||
tcp_kill_prio(prio);
|
tcp_kill_prio(prio);
|
||||||
}
|
}
|
||||||
@ -1471,9 +1476,9 @@ tcp_alloc(u8_t prio)
|
|||||||
|
|
||||||
tcp_pcb_num_cal(&tcp_pcb_num);
|
tcp_pcb_num_cal(&tcp_pcb_num);
|
||||||
if (tcp_pcb_num.total >= MEMP_NUM_TCP_PCB){
|
if (tcp_pcb_num.total >= MEMP_NUM_TCP_PCB){
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: no available tcp pcb %d %d %d %d %d %d %d\n",
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: no available tcp pcb %d %d %d %d %d %d %d %d\n",
|
||||||
tcp_pcb_num.total, tcp_pcb_num.time_wait, tcp_pcb_num.last_ack, tcp_pcb_num.closing,
|
tcp_pcb_num.total, tcp_pcb_num.time_wait, tcp_pcb_num.last_ack, tcp_pcb_num.closing,
|
||||||
tcp_pcb_num.fin_wait2, tcp_pcb_num.listen, tcp_pcb_num.bound));
|
tcp_pcb_num.fin_wait2, tcp_pcb_num.fin_wait1, tcp_pcb_num.listen, tcp_pcb_num.bound));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,25 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
|
|||||||
#include "lwip/mem.h"
|
#include "lwip/mem.h"
|
||||||
|
|
||||||
#define memp_init()
|
#define memp_init()
|
||||||
#define memp_malloc(type) mem_malloc(memp_pools[type]->size); ESP_CNT_MEM_MALLOC_INC(type)
|
#if ESP_CNT_DEBUG
|
||||||
#define memp_free(type, mem) mem_free(mem); ESP_CNT_MEM_FREE_INC(type)
|
static inline void* memp_malloc(int type)
|
||||||
|
{
|
||||||
|
ESP_CNT_MEM_MALLOC_INC(type);
|
||||||
|
return mem_malloc(memp_pools[type]->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void memp_free(int type, void *mem)
|
||||||
|
{
|
||||||
|
ESP_CNT_MEM_FREE_INC(type);
|
||||||
|
mem_free(mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
//#define memp_malloc(type) mem_malloc(memp_pools[type]->size); ESP_CNT_MEM_MALLOC_INC(type)
|
||||||
|
//#define memp_free(type, mem) mem_free(mem); ESP_CNT_MEM_FREE_INC(type)
|
||||||
|
#else
|
||||||
|
#define memp_malloc(type) mem_malloc(memp_pools[type]->size)
|
||||||
|
#define memp_free(type, mem) mem_free(mem)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
|
#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
|
||||||
const struct memp_desc memp_ ## name = { \
|
const struct memp_desc memp_ ## name = { \
|
||||||
|
Loading…
Reference in New Issue
Block a user