[mdns] Keep the roaming tick skip as a performance guard

Each failing send spins sendTimeout() for 50 ms while the radio is off
channel, so skip the tick on is_roaming_scan_active() instead of stalling
the loop; the wifi accessor removal is no longer needed.
This commit is contained in:
J. Nick Koston
2026-09-05 21:20:07 +02:00
parent 7bb1ae6520
commit 68612eb8af
2 changed files with 14 additions and 1 deletions
+10 -1
View File
@@ -89,7 +89,16 @@ static void register_esp8266(MDNSComponent *, StaticVector<MDNSService, MDNS_SER
#ifdef USE_MDNS_EVENT_DRIVEN_POLLING
void MDNSComponent::start_polling_window_() {
// uint32_t-ID set_interval/set_timeout already does atomic cancel-and-add.
this->set_interval(MDNS_POLL_ID, MDNS_UPDATE_INTERVAL_MS, []() { mdns_responder.update_guarded(); });
this->set_interval(MDNS_POLL_ID, MDNS_UPDATE_INTERVAL_MS, []() {
#ifdef USE_MDNS_WIFI_LISTENER
// Every send fails while the radio is off channel or no interface is up, and each one
// spins sendTimeout() for 50 ms; skip the tick rather than stall the loop for nothing.
auto *wifi = wifi::global_wifi_component;
if (wifi->is_roaming_scan_active() || (!wifi->is_connected() && !wifi->is_ap_active()))
return;
#endif
mdns_responder.update_guarded();
});
this->set_timeout(MDNS_POLL_STOP_ID, MDNS_POLL_WINDOW_MS, [this]() { this->cancel_interval(MDNS_POLL_ID); });
}
#endif
+4
View File
@@ -476,6 +476,10 @@ class WiFiComponent final : public Component {
/// True while a post-connect roaming scan holds the radio off-channel.
bool is_roaming_scan_active() const { return this->roaming_state_ == RoamingState::SCANNING; }
/// True while a post-connect roam is in progress (scanning off-channel, reassociating,
/// or recovering from a failed roam).
bool is_roaming() const { return this->roaming_state_ != RoamingState::IDLE; }
#ifdef USE_ESP32
/// esp_netif handle of the station interface, used by network for default-route
/// arbitration. nullptr until wifi_lazy_init_() has run.