From 825a2e9a257a8467679c4056452c7c12361f2778 Mon Sep 17 00:00:00 2001 From: Emil Muratov Date: Sat, 14 Dec 2024 23:32:26 +0900 Subject: [PATCH] limit _async_service_task watchdog to guard only recv/poll callbacks others are not critical and could skip setting/removing watchdog each time --- src/AsyncTCP.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/AsyncTCP.cpp b/src/AsyncTCP.cpp index ae79d4c..a7991d7 100644 --- a/src/AsyncTCP.cpp +++ b/src/AsyncTCP.cpp @@ -175,7 +175,7 @@ static inline bool _get_async_event(lwip_event_packet_t** e) { if (xQueueReceive(_async_queue, &next_pkt, 0) == pdPASS){ free(next_pkt); next_pkt = NULL; - log_w("coalescing polls, async callback might be too slow!"); + log_d("coalescing polls, async callback might be too slow!"); } else return true; } else @@ -259,15 +259,23 @@ static void _async_service_task(void* pvParameters) { for (;;) { if (_get_async_event(&packet)) { #if CONFIG_ASYNC_TCP_USE_WDT - if (esp_task_wdt_add(NULL) != ESP_OK) { - log_e("Failed to add async task to WDT"); + switch((size_t)packet->arg){ + case LWIP_TCP_RECV: + case LWIP_TCP_POLL: + if (esp_task_wdt_add(NULL) != ESP_OK) { + log_e("Failed to add async task to WDT"); + } + _handle_async_event(packet); + if (esp_task_wdt_delete(NULL) != ESP_OK) { + log_e("Failed to remove async task from WDT"); + } + break; + + default: + _handle_async_event(packet); } -#endif +#else _handle_async_event(packet); -#if CONFIG_ASYNC_TCP_USE_WDT - if (esp_task_wdt_delete(NULL) != ESP_OK) { - log_e("Failed to remove loop task from WDT"); - } #endif } }