From 0bfb294f322624cbeb6e1beb467e8e108335a89f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 26 Feb 2026 06:38:23 -1000 Subject: [PATCH] Update comments to reflect multi-platform fast select scope Co-Authored-By: Claude Opus 4.6 --- esphome/core/application.cpp | 5 +++-- esphome/core/application.h | 7 ++++--- esphome/core/lwip_fast_select.c | 9 +++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/esphome/core/application.cpp b/esphome/core/application.cpp index 6f367de14d..83aa281aa5 100644 --- a/esphome/core/application.cpp +++ b/esphome/core/application.cpp @@ -616,8 +616,9 @@ void Application::unregister_socket_fd(int fd) { continue; // Swap with last element and pop - O(1) removal since order doesn't matter. - // No need to unhook the netconn callback on ESP32 — all LwIP sockets share - // the same static event_callback, and the socket will be closed by the caller. + // No need to unhook the netconn callback on fast select platforms — all LwIP + // sockets share the same static event_callback, and the socket will be closed + // by the caller. if (i < this->socket_fds_.size() - 1) this->socket_fds_[i] = this->socket_fds_.back(); this->socket_fds_.pop_back(); diff --git a/esphome/core/application.h b/esphome/core/application.h index 42e5993cb7..0cc29af8e7 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -511,9 +511,10 @@ class Application { #ifdef USE_SOCKET_SELECT_SUPPORT /// Fast path for Socket::ready() via friendship - skips negative fd check. - /// Main loop only — on ESP32, reads rcvevent via lwip_socket_dbg_get_socket() - /// which has no refcount; safe only because the main loop owns socket lifetime - /// (creates, reads, and closes sockets on the same thread). + /// Main loop only — with USE_LWIP_FAST_SELECT, reads rcvevent via + /// lwip_socket_dbg_get_socket(), which has no refcount; safe only because + /// the main loop owns socket lifetime (creates, reads, and closes sockets + /// on the same thread). #ifdef USE_LWIP_FAST_SELECT bool is_socket_ready_(int fd) const { return esphome_lwip_socket_has_data(fd); } #else diff --git a/esphome/core/lwip_fast_select.c b/esphome/core/lwip_fast_select.c index b6a4ac2961..88cf23b67e 100644 --- a/esphome/core/lwip_fast_select.c +++ b/esphome/core/lwip_fast_select.c @@ -5,7 +5,8 @@ // 1. lwip/priv/sockets_priv.h conflicts with C++ compilation units // 2. The netconn callback is a C function pointer // -// defines.h is force-included by the build system (-include flag), providing USE_LWIP_FAST_SELECT etc. +// USE_ESP32 and USE_LIBRETINY platform flags (-D) control compilation of this file. +// See the guard at the bottom of the header comment for details. // // Thread safety analysis // ====================== @@ -104,9 +105,9 @@ // critical sections). Multiple concurrent xTaskNotifyGive calls are safe — // the notification count simply increments. -// USE_ESP32 and USE_LIBRETINY are build flags (-D), always available to .c files. -// USE_LWIP_FAST_SELECT is in the generated defines.h (force-included for .cpp but -// may not reach .c files on all build systems), so we use platform flags here. +// USE_ESP32 and USE_LIBRETINY are compiler -D flags, so they are always visible in this .c file. +// Feature macros like USE_LWIP_FAST_SELECT may come from generated headers that are not included here, +// so this implementation is enabled based on platform flags instead of USE_LWIP_FAST_SELECT. #if defined(USE_ESP32) || defined(USE_LIBRETINY) // LwIP headers must come first — they define netconn_callback, struct lwip_sock, etc.