mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lwip: add socket tx flow control
This commit is contained in:
parent
db93bceb55
commit
a28ef1776e
@ -389,18 +389,18 @@ static void lwip_socket_drop_registered_memberships(int s);
|
|||||||
|
|
||||||
#ifdef LWIP_ESP8266
|
#ifdef LWIP_ESP8266
|
||||||
extern size_t system_get_free_heap_size(void);
|
extern size_t system_get_free_heap_size(void);
|
||||||
|
extern bool esp_wifi_tx_is_stop(void);
|
||||||
#define DELAY_WHEN_MEMORY_NOT_ENOUGH() \
|
#define ESP32_TX_FLOW_CTRL() \
|
||||||
do{\
|
do{\
|
||||||
uint8_t _wait_delay = 0;\
|
uint8_t _wait_delay = 0;\
|
||||||
while (system_get_free_heap_size() < HEAP_HIGHWAT){\
|
while ((system_get_free_heap_size() < HEAP_HIGHWAT) || esp_wifi_tx_is_stop()){\
|
||||||
vTaskDelay(_wait_delay/portTICK_RATE_MS);\
|
vTaskDelay(_wait_delay/portTICK_RATE_MS);\
|
||||||
if (_wait_delay < 64) _wait_delay *= 2;\
|
if (_wait_delay < 64) _wait_delay *= 2;\
|
||||||
}\
|
}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define DELAY_WHEN_MEMORY_NOT_ENOUGH()
|
#define ESP32_TX_FLOW_CTRL()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** The global array of available sockets */
|
/** The global array of available sockets */
|
||||||
@ -1219,7 +1219,7 @@ lwip_send(int s, const void *data, size_t size, int flags)
|
|||||||
#endif /* (LWIP_UDP || LWIP_RAW) */
|
#endif /* (LWIP_UDP || LWIP_RAW) */
|
||||||
}
|
}
|
||||||
|
|
||||||
DELAY_WHEN_MEMORY_NOT_ENOUGH();
|
ESP32_TX_FLOW_CTRL();
|
||||||
|
|
||||||
write_flags = NETCONN_COPY |
|
write_flags = NETCONN_COPY |
|
||||||
((flags & MSG_MORE) ? NETCONN_MORE : 0) |
|
((flags & MSG_MORE) ? NETCONN_MORE : 0) |
|
||||||
@ -1402,7 +1402,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags,
|
|||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
}
|
}
|
||||||
|
|
||||||
DELAY_WHEN_MEMORY_NOT_ENOUGH();
|
ESP32_TX_FLOW_CTRL();
|
||||||
|
|
||||||
if ((to != NULL) && !SOCK_ADDR_TYPE_MATCH(to, sock)) {
|
if ((to != NULL) && !SOCK_ADDR_TYPE_MATCH(to, sock)) {
|
||||||
/* sockaddr does not match socket type (IPv4/IPv6) */
|
/* sockaddr does not match socket type (IPv4/IPv6) */
|
||||||
|
Loading…
Reference in New Issue
Block a user