mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-09 14:15:57 +00:00
feat(mbedtls): Add configuration to control dynamic buffer strategy in mbedtls
Problem: 1. In low-memory scenarios, the dynamic buffer feature can fail due to memory fragmentation. 2. It requires a contiguous 16KB heap chunk, but continuous allocation and deallocation of the RX buffer can lead to fragmentation. 3. If another component allocates memory between these operations, it can break up the available 16KB block, causing allocation failure. Solution: 1. Introduce configurable strategy for using dynamic buffers in TLS connections. 2. For example, convert RX buffers to static after the TLS handshake. 3. Allow users to select the strategy via a new field in the esp_http_client_cfg_t structure. 4. The strategy can be controlled independently for each TLS session.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -138,6 +138,11 @@ typedef enum {
|
||||
HTTP_ADDR_TYPE_INET6 = AF_INET6, /**< IPv6 address family. */
|
||||
} esp_http_client_addr_type_t;
|
||||
|
||||
typedef enum {
|
||||
HTTP_TLS_DYN_BUF_RX_STATIC = 1, /*!< Strategy to disable dynamic RX buffer allocations and convert to static allocation post-handshake, reducing memory fragmentation */
|
||||
HTTP_TLS_DYN_BUF_STRATEGY_MAX, /*!< to indicate max */
|
||||
} esp_http_client_tls_dyn_buf_strategy_t;
|
||||
|
||||
/**
|
||||
* @brief HTTP configuration
|
||||
*/
|
||||
@@ -200,6 +205,10 @@ typedef struct {
|
||||
struct esp_transport_item_t *transport;
|
||||
#endif
|
||||
esp_http_client_addr_type_t addr_type; /*!< Address type used in http client configurations */
|
||||
|
||||
#if CONFIG_MBEDTLS_DYNAMIC_BUFFER
|
||||
esp_http_client_tls_dyn_buf_strategy_t tls_dyn_buf_strategy; /*!< TLS dynamic buffer strategy */
|
||||
#endif
|
||||
} esp_http_client_config_t;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user