mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-18 18:40:13 +00:00
fix: Add config option to set timeout for posting events
Event posting to the event loop should not hinder the working of HTTP Client or HTTP Server. This commit add a config option to set the timeout for posting the events to the loop. Closes https://github.com/espressif/esp-idf/issues/13641
This commit is contained in:
@@ -6,4 +6,11 @@ menu "ESP HTTPS server"
|
||||
help
|
||||
Enable ESP HTTPS server component
|
||||
|
||||
config ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT
|
||||
int "Time in millisecond to wait for posting event"
|
||||
default 2000
|
||||
help
|
||||
This config option helps in setting the time in millisecond to wait for event to be posted to the
|
||||
system default event loop. Set it to -1 if you need to set timeout to portMAX_DELAY.
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -25,9 +25,16 @@ typedef struct httpd_ssl_transport_ctx {
|
||||
|
||||
ESP_EVENT_DEFINE_BASE(ESP_HTTPS_SERVER_EVENT);
|
||||
|
||||
#if CONFIG_ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT == -1
|
||||
#define ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT portMAX_DELAY
|
||||
#else
|
||||
#define ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT pdMS_TO_TICKS(CONFIG_ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT)
|
||||
#endif
|
||||
|
||||
|
||||
static void http_dispatch_event_to_event_loop(int32_t event_id, const void* event_data, size_t event_data_size)
|
||||
{
|
||||
esp_err_t err = esp_event_post(ESP_HTTPS_SERVER_EVENT, event_id, event_data, event_data_size, portMAX_DELAY);
|
||||
esp_err_t err = esp_event_post(ESP_HTTPS_SERVER_EVENT, event_id, event_data, event_data_size, ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to post http_client event: %"PRId32", error: %s", event_id, esp_err_to_name(err));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user