mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
Merge branch 'fix/async_handler_example_stack_overflow_issue_v5.3' into 'release/v5.3'
fix(esp_http_server): Async handler example stack overflow fix (v5.3) See merge request espressif/esp-idf!38997
This commit is contained in:
@ -7,4 +7,10 @@ menu "Example Configuration"
|
|||||||
The maximum number of simultaneous async requests that the
|
The maximum number of simultaneous async requests that the
|
||||||
web server can handle.
|
web server can handle.
|
||||||
|
|
||||||
|
config EXAMPLE_ASYNC_WORKER_TASK_STACK_SIZE
|
||||||
|
int "Async Worker Task Stack Size"
|
||||||
|
default 2560
|
||||||
|
help
|
||||||
|
The stack size allocated for each async worker task.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define ASYNC_WORKER_TASK_PRIORITY 5
|
#define ASYNC_WORKER_TASK_PRIORITY 5
|
||||||
#define ASYNC_WORKER_TASK_STACK_SIZE 2048
|
#define ASYNC_WORKER_TASK_STACK_SIZE CONFIG_EXAMPLE_ASYNC_WORKER_TASK_STACK_SIZE
|
||||||
|
|
||||||
static const char *TAG = "example";
|
static const char *TAG = "example";
|
||||||
|
|
||||||
@ -133,7 +133,11 @@ static esp_err_t long_async_handler(httpd_req_t *req)
|
|||||||
// send a request count
|
// send a request count
|
||||||
char s[100];
|
char s[100];
|
||||||
snprintf(s, sizeof(s), "<div>req: %u</div>\n", req_count);
|
snprintf(s, sizeof(s), "<div>req: %u</div>\n", req_count);
|
||||||
httpd_resp_sendstr_chunk(req, s);
|
esp_err_t err = httpd_resp_sendstr_chunk(req, s);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to send string chunk: %s", esp_err_to_name(err));
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
// then every second, send a "tick"
|
// then every second, send a "tick"
|
||||||
for (int i = 0; i < 60; i++) {
|
for (int i = 0; i < 60; i++) {
|
||||||
@ -145,11 +149,19 @@ static esp_err_t long_async_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
// send a tick
|
// send a tick
|
||||||
snprintf(s, sizeof(s), "<div>%u</div>\n", i);
|
snprintf(s, sizeof(s), "<div>%u</div>\n", i);
|
||||||
httpd_resp_sendstr_chunk(req, s);
|
err = httpd_resp_sendstr_chunk(req, s);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to send string chunk: %s", esp_err_to_name(err));
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send "complete"
|
// send "complete"
|
||||||
httpd_resp_sendstr_chunk(req, NULL);
|
err = httpd_resp_sendstr_chunk(req, NULL);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to send string chunk: %s", esp_err_to_name(err));
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user