Update comments to reflect multi-platform fast select scope

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-02-26 06:38:23 -10:00
parent 4c4a22b0c0
commit 0bfb294f32
3 changed files with 12 additions and 9 deletions

View File

@@ -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();

View File

@@ -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

View File

@@ -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.