feat(esp_http_server): Make HTTP(S)_SERVER_EVENT events optional

Make it possible to disable http(s) server events. This improves
performance of the server, as http server creates events on every signle
read or write to the socket.
This commit is contained in:
Jimmy Wennlund
2025-03-17 11:01:04 +01:00
committed by Hrushikesh Bhosale
parent 8f3d8b41c3
commit 6036ec961d
9 changed files with 53 additions and 5 deletions

View File

@@ -23,6 +23,7 @@ typedef struct httpd_ssl_transport_ctx {
httpd_ssl_ctx_t *global_ctx;
} httpd_ssl_transport_ctx_t;
#ifdef CONFIG_ESP_HTTPS_SERVER_EVENTS
ESP_EVENT_DEFINE_BASE(ESP_HTTPS_SERVER_EVENT);
#if CONFIG_ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT == -1
@@ -31,7 +32,6 @@ ESP_EVENT_DEFINE_BASE(ESP_HTTPS_SERVER_EVENT);
#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, ESP_HTTPS_SERVER_EVENT_POST_TIMEOUT);
@@ -39,6 +39,9 @@ static void http_dispatch_event_to_event_loop(int32_t event_id, const void* even
ESP_LOGE(TAG, "Failed to post http_client event: %"PRId32", error: %s", event_id, esp_err_to_name(err));
}
}
#else // CONFIG_ESP_HTTPS_SERVER_EVENTS
#define http_dispatch_event_to_event_loop(event_id, event_data, event_data_size) do {} while (0)
#endif // CONFIG_ESP_HTTPS_SERVER_EVENTS
/**
* SSL socket close handler