Skip to content

Commit

Permalink
change(components/esp_http_server): add task_caps configuration
Browse files Browse the repository at this point in the history
The HTTP server is not a critical component, it would be nice if we can
control the task caps by using configuration.

Signed-off-by: Alon Bar-Lev <[email protected]>
  • Loading branch information
alonbl committed Oct 31, 2023
1 parent b4268c8 commit a8f7f4b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions components/esp_http_server/include/esp_http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ initializer that should be kept in sync
.task_priority = tskIDLE_PRIORITY+5, \
.stack_size = 4096, \
.core_id = tskNO_AFFINITY, \
.task_caps = MALLOC_CAP_DEFAULT, \
.server_port = 80, \
.ctrl_port = ESP_HTTPD_DEF_CTRL_PORT, \
.max_open_sockets = 7, \
Expand Down Expand Up @@ -168,6 +169,7 @@ typedef struct httpd_config {
unsigned task_priority; /*!< Priority of FreeRTOS task which runs the server */
size_t stack_size; /*!< The maximum stack size allowed for the server task */
BaseType_t core_id; /*!< The core the HTTP server task will run on */
uint32_t task_caps; /*!< The memory capabilities to use when allocating the task */

/**
* TCP Port number for receiving and transmitting HTTP traffic
Expand Down
3 changes: 2 additions & 1 deletion components/esp_http_server/src/httpd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ esp_err_t httpd_start(httpd_handle_t *handle, const httpd_config_t *config)
hd->config.stack_size,
hd->config.task_priority,
httpd_thread, hd,
hd->config.core_id) != ESP_OK) {
hd->config.core_id,
hd->config.task_caps) != ESP_OK) {
/* Failed to launch task */
httpd_delete(hd);
return ESP_ERR_HTTPD_TASK;
Expand Down
4 changes: 2 additions & 2 deletions components/esp_http_server/src/port/esp32/osal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ typedef TaskHandle_t othread_t;
static inline int httpd_os_thread_create(othread_t *thread,
const char *name, uint16_t stacksize, int prio,
void (*thread_routine)(void *arg), void *arg,
BaseType_t core_id)
BaseType_t core_id, uint32_t caps)
{
int ret = xTaskCreatePinnedToCore(thread_routine, name, stacksize, arg, prio, thread, core_id);
int ret = xTaskCreatePinnedToCoreWithCaps(thread_routine, name, stacksize, arg, prio, thread, core_id, caps);
if (ret == pdPASS) {
return OS_SUCCESS;
}
Expand Down
2 changes: 1 addition & 1 deletion components/esp_http_server/src/port/linux/osal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef TaskHandle_t othread_t;
static inline int httpd_os_thread_create(othread_t *thread,
const char *name, uint16_t stacksize, int prio,
void (*thread_routine)(void *arg), void *arg,
BaseType_t core_id)
BaseType_t core_id, uint32_t caps)
{
pthread_attr_t thread_attr;
pthread_attr_init(&thread_attr);
Expand Down
1 change: 1 addition & 0 deletions components/esp_https_server/include/esp_https_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t;
.task_priority = tskIDLE_PRIORITY+5, \
.stack_size = 10240, \
.core_id = tskNO_AFFINITY, \
.task_caps = MALLOC_CAP_DEFAULT, \
.server_port = 0, \
.ctrl_port = ESP_HTTPD_DEF_CTRL_PORT+1, \
.max_open_sockets = 4, \
Expand Down

0 comments on commit a8f7f4b

Please sign in to comment.