mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-23 01:58:24 +08:00
fix(lwip): fix TCP pbuf memory leak
Disable TCP cache and retry function.
This commit is contained in:
@ -427,8 +427,10 @@ again:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ESP_TCP
|
||||||
extern void send_from_list();
|
extern void send_from_list();
|
||||||
send_from_list();
|
send_from_list();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ESP_UDP
|
#if ESP_UDP
|
||||||
udp_sync_proc();
|
udp_sync_proc();
|
||||||
|
@ -19,32 +19,12 @@
|
|||||||
#include "esp8266/eagle_soc.h"
|
#include "esp8266/eagle_soc.h"
|
||||||
|
|
||||||
#ifdef ESP_LWIP
|
#ifdef ESP_LWIP
|
||||||
/*
|
#if MEMP_SIZE != 0
|
||||||
* @brief allocate an only DRAM memory block for LWIP pbuf
|
#error "MEMP_SIZE must be 0"
|
||||||
*
|
#else /* MEMP_SIZE != 0 */
|
||||||
* @param s memory size
|
size_t memp_malloc_get_size(size_t type)
|
||||||
*
|
|
||||||
* @return memory block pointer
|
|
||||||
*/
|
|
||||||
void *mem_malloc_ll(size_t s)
|
|
||||||
{
|
{
|
||||||
void *return_addr = (void *)__builtin_return_address(0);
|
return memp_pools[type]->size;
|
||||||
|
|
||||||
return _heap_caps_malloc(s, MALLOC_CAP_8BIT, return_addr, 0);
|
|
||||||
}
|
}
|
||||||
|
#endif /* MEMP_SIZE != 0 */
|
||||||
void *memp_malloc_ll(size_t type)
|
#endif /* ESP_LWIP */
|
||||||
{
|
|
||||||
extern const struct memp_desc* const memp_pools[MEMP_MAX];
|
|
||||||
|
|
||||||
uint8_t *p;
|
|
||||||
const struct memp_desc *desc = memp_pools[type];
|
|
||||||
|
|
||||||
p = (uint8_t *)mem_malloc_ll(MEMP_SIZE + MEMP_ALIGN_SIZE(desc->size));
|
|
||||||
if (p)
|
|
||||||
p += MEMP_SIZE;
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -213,6 +213,8 @@
|
|||||||
#define ESP_LWIP_MEM_DBG 1
|
#define ESP_LWIP_MEM_DBG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
size_t memp_malloc_get_size(size_t type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief allocate an only DRAM memory block for LWIP pbuf
|
* @brief allocate an only DRAM memory block for LWIP pbuf
|
||||||
*
|
*
|
||||||
@ -220,7 +222,7 @@
|
|||||||
*
|
*
|
||||||
* @return memory block pointer
|
* @return memory block pointer
|
||||||
*/
|
*/
|
||||||
void *mem_malloc_ll(size_t s);
|
#define mem_malloc_ll(s) heap_caps_malloc(s, MALLOC_CAP_8BIT)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief allocate an only DRAM memory pool for LWIP pbuf
|
* @brief allocate an only DRAM memory pool for LWIP pbuf
|
||||||
@ -229,7 +231,7 @@ void *mem_malloc_ll(size_t s);
|
|||||||
*
|
*
|
||||||
* @return memory pool pointer
|
* @return memory pool pointer
|
||||||
*/
|
*/
|
||||||
void *memp_malloc_ll(size_t type);
|
#define memp_malloc_ll(type) heap_caps_malloc(memp_malloc_get_size(type), MALLOC_CAP_8BIT)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ void wifi_station_set_default_hostname(uint8_t* hwaddr);
|
|||||||
#define IFNAME0 'e'
|
#define IFNAME0 'e'
|
||||||
#define IFNAME1 'n'
|
#define IFNAME1 'n'
|
||||||
|
|
||||||
|
#if ESP_TCP
|
||||||
typedef struct pbuf_send_list {
|
typedef struct pbuf_send_list {
|
||||||
struct pbuf_send_list* next;
|
struct pbuf_send_list* next;
|
||||||
struct pbuf* p;
|
struct pbuf* p;
|
||||||
@ -44,8 +44,10 @@ typedef struct pbuf_send_list {
|
|||||||
|
|
||||||
static pbuf_send_list_t* pbuf_list_head = NULL;
|
static pbuf_send_list_t* pbuf_list_head = NULL;
|
||||||
static int pbuf_send_list_num = 0;
|
static int pbuf_send_list_num = 0;
|
||||||
|
#endif
|
||||||
static int low_level_send_cb(esp_aio_t* aio);
|
static int low_level_send_cb(esp_aio_t* aio);
|
||||||
|
|
||||||
|
#if ESP_TCP
|
||||||
static inline bool check_pbuf_to_insert(struct pbuf* p)
|
static inline bool check_pbuf_to_insert(struct pbuf* p)
|
||||||
{
|
{
|
||||||
uint8_t* buf = (uint8_t*)p->payload;
|
uint8_t* buf = (uint8_t*)p->payload;
|
||||||
@ -172,6 +174,7 @@ void send_from_list()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this function, the hardware should be initialized.
|
* In this function, the hardware should be initialized.
|
||||||
@ -213,6 +216,8 @@ static void low_level_init(struct netif* netif)
|
|||||||
static int low_level_send_cb(esp_aio_t* aio)
|
static int low_level_send_cb(esp_aio_t* aio)
|
||||||
{
|
{
|
||||||
struct pbuf* pbuf = aio->arg;
|
struct pbuf* pbuf = aio->arg;
|
||||||
|
|
||||||
|
#if ESP_TCP
|
||||||
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
|
wifi_tx_status_t* status = (wifi_tx_status_t*) & (aio->ret);
|
||||||
|
|
||||||
if ((TX_STATUS_SUCCESS != status->wifi_tx_result) && check_pbuf_to_insert(pbuf)) {
|
if ((TX_STATUS_SUCCESS != status->wifi_tx_result) && check_pbuf_to_insert(pbuf)) {
|
||||||
@ -235,6 +240,7 @@ static int low_level_send_cb(esp_aio_t* aio)
|
|||||||
status->wifi_tx_result, status->wifi_tx_lrc, status->wifi_tx_src, status->wifi_tx_rate));
|
status->wifi_tx_result, status->wifi_tx_lrc, status->wifi_tx_src, status->wifi_tx_rate));
|
||||||
insert_to_list(aio->fd, aio->arg);
|
insert_to_list(aio->fd, aio->arg);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pbuf_free(pbuf);
|
pbuf_free(pbuf);
|
||||||
|
|
||||||
@ -350,7 +356,9 @@ static int8_t low_level_output(struct netif* netif, struct pbuf* p)
|
|||||||
|
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
if (err == ERR_MEM) {
|
if (err == ERR_MEM) {
|
||||||
|
#if ESP_TCP
|
||||||
insert_to_list(aio.fd, p);
|
insert_to_list(aio.fd, p);
|
||||||
|
#endif
|
||||||
err = ERR_OK;
|
err = ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user