From 291cb11436ab8dcd49f2d16be79e892f4a197130 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 27 May 2025 09:47:44 -0500 Subject: [PATCH] debvug --- esphome/core/application.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/esphome/core/application.cpp b/esphome/core/application.cpp index e40845312d..2cba326107 100644 --- a/esphome/core/application.cpp +++ b/esphome/core/application.cpp @@ -8,8 +8,18 @@ #endif #ifdef FD_SETSIZE -#include #include +#ifdef USE_ESP32 +#include +#elif defined(USE_ESP8266) +#include +#include +extern "C" { +#include +} +#else +#include +#endif #endif namespace esphome { @@ -136,12 +146,14 @@ void Application::loop() { tv.tv_usec = (delay_time % 1000) * 1000; // Call select with timeout - int ret = select(this->max_fd_ + 1, &this->read_fds_, nullptr, nullptr, &tv); + int ret = ::select(this->max_fd_ + 1, &this->read_fds_, nullptr, nullptr, &tv); if (ret < 0 && errno != EINTR) { // Log error but continue - fall back to delay ESP_LOGW(TAG, "select() failed with errno %d", errno); delay(delay_time); + } else if (ret > 0) { + ESP_LOGVV(TAG, "select() returned %d ready socket(s)", ret); } // If ret == 0, timeout occurred (normal) // If ret > 0, socket(s) ready for reading (will be handled in component loops) @@ -223,6 +235,8 @@ void Application::register_socket_fd(int fd) { if (fd > this->max_fd_) { this->max_fd_ = fd; } + + ESP_LOGD(TAG, "Registered socket fd %d (total: %zu)", fd, this->socket_fds_.size()); } void Application::unregister_socket_fd(int fd) { @@ -238,6 +252,8 @@ void Application::unregister_socket_fd(int fd) { } else if (this->socket_fds_.empty()) { this->max_fd_ = -1; } + + ESP_LOGD(TAG, "Unregistered socket fd %d (remaining: %zu)", fd, this->socket_fds_.size()); } bool Application::is_socket_ready(int fd) const {