From a121bf17f017d08590be9df081ac4203acf9f082 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 5 Sep 2026 21:31:05 +0200 Subject: [PATCH] [mdns] Fold the receive branch into the onRx handler --- esphome/components/mdns/mdns_esp8266.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/esphome/components/mdns/mdns_esp8266.cpp b/esphome/components/mdns/mdns_esp8266.cpp index cd2ae8ef97..ab7b7d870c 100644 --- a/esphome/components/mdns/mdns_esp8266.cpp +++ b/esphome/components/mdns/mdns_esp8266.cpp @@ -29,8 +29,15 @@ class GuardedMDNSResponder : public ::esp8266::MDNSImplementation::MDNSResponder (this->*fn)(); return; } - // Set every time: a restart replaces the context together with its stock handler - ctx->onRx([this]() { this->on_rx_(); }); + // Set every time: a restart replaces the context together with its stock handler. + // Runs from lwIP in the SYS context. + ctx->onRx([this]() { + if (this->in_loop_call_) { + this->pending_rx_++; + } else { + this->_callProcess(); + } + }); this->pending_rx_ = 0; this->in_loop_call_ = true; (this->*fn)(); @@ -42,15 +49,6 @@ class GuardedMDNSResponder : public ::esp8266::MDNSImplementation::MDNSResponder this->in_loop_call_ = false; } - // lwIP receive callback (SYS context) - void on_rx_() { - if (this->in_loop_call_) { - this->pending_rx_++; - } else { - this->_callProcess(); - } - } - volatile bool in_loop_call_{false}; volatile uint8_t pending_rx_{0}; };