From e2a36ed6c2a92ee2947db3284b76acf8579c0e08 Mon Sep 17 00:00:00 2001 From: hreintke Date: Wed, 27 Jul 2022 23:33:18 +0200 Subject: [PATCH] MDNS : Also increase # of sends when a send fails (#8641) This solves the root cause of the infinite sending of host probes when STA is not connected. --- libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp b/libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp index 3d79f05ebc..e357cbab52 100644 --- a/libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp +++ b/libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp @@ -1395,11 +1395,18 @@ namespace MDNSImplementation { if ((bResult = _sendHostProbe())) { - DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( - PSTR("[MDNSResponder] _updateProbeStatus: Did sent host probe\n\n"));); - m_HostProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY); - ++m_HostProbeInformation.m_u8SentCount; + DEBUG_EX_INFO( + DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Did sent " + "host probe to all links \n\n"));); + } + else + { + DEBUG_EX_INFO( + DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Did not " + "sent host probe to all links\n\n"));); } + m_HostProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY); + ++m_HostProbeInformation.m_u8SentCount; } else // Probing finished { @@ -1422,23 +1429,22 @@ namespace MDNSImplementation else if ((ProbingStatus_Done == m_HostProbeInformation.m_ProbingStatus) && (m_HostProbeInformation.m_Timeout.expired())) { - if ((bResult = _announce(true, false))) // Don't announce services here - { - ++m_HostProbeInformation.m_u8SentCount; + _announce(true, false); // Don't announce services here - if (MDNS_ANNOUNCE_COUNT > m_HostProbeInformation.m_u8SentCount) - { - m_HostProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY); - DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( - PSTR("[MDNSResponder] _updateProbeStatus: Announcing host (%d).\n\n"), - m_HostProbeInformation.m_u8SentCount);); - } - else - { - m_HostProbeInformation.m_Timeout.resetToNeverExpires(); - DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( - PSTR("[MDNSResponder] _updateProbeStatus: Done host announcing.\n\n"));); - } + ++m_HostProbeInformation.m_u8SentCount; + + if (MDNS_ANNOUNCE_COUNT > m_HostProbeInformation.m_u8SentCount) + { + m_HostProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY); + DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( + PSTR("[MDNSResponder] _updateProbeStatus: Announcing host (%d).\n\n"), + m_HostProbeInformation.m_u8SentCount);); + } + else + { + m_HostProbeInformation.m_Timeout.resetToNeverExpires(); + DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( + PSTR("[MDNSResponder] _updateProbeStatus: Done host announcing.\n\n"));); } } @@ -1464,12 +1470,21 @@ namespace MDNSImplementation if ((bResult = _sendServiceProbe(*pService))) { DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( - PSTR("[MDNSResponder] _updateProbeStatus: Did sent service probe " + PSTR("[MDNSResponder] _updateProbeStatus: Did sent service probe to " + "all links " "(%u)\n\n"), (pService->m_ProbeInformation.m_u8SentCount + 1));); - pService->m_ProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY); - ++pService->m_ProbeInformation.m_u8SentCount; } + else + { + DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( + PSTR("[MDNSResponder] _updateProbeStatus: Did not sent service probe " + "to all links" + "(%u)\n\n"), + (pService->m_ProbeInformation.m_u8SentCount + 1));); + } + pService->m_ProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY); + ++pService->m_ProbeInformation.m_u8SentCount; } else // Probing finished { @@ -1495,28 +1510,27 @@ namespace MDNSImplementation else if ((ProbingStatus_Done == pService->m_ProbeInformation.m_ProbingStatus) && (pService->m_ProbeInformation.m_Timeout.expired())) { - if ((bResult = _announceService(*pService))) // Announce service - { - ++pService->m_ProbeInformation.m_u8SentCount; + _announceService(*pService); // Announce service - if (MDNS_ANNOUNCE_COUNT > pService->m_ProbeInformation.m_u8SentCount) - { - pService->m_ProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY); - DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( - PSTR("[MDNSResponder] _updateProbeStatus: Announcing service %s.%s.%s " - "(%d)\n\n"), - (pService->m_pcName ?: m_pcHostname), pService->m_pcService, - pService->m_pcProtocol, pService->m_ProbeInformation.m_u8SentCount);); - } - else - { - pService->m_ProbeInformation.m_Timeout.resetToNeverExpires(); - DEBUG_EX_INFO( - DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Done " - "service announcing for %s.%s.%s\n\n"), - (pService->m_pcName ?: m_pcHostname), - pService->m_pcService, pService->m_pcProtocol);); - } + ++pService->m_ProbeInformation.m_u8SentCount; + + if (MDNS_ANNOUNCE_COUNT > pService->m_ProbeInformation.m_u8SentCount) + { + pService->m_ProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY); + DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P( + PSTR("[MDNSResponder] _updateProbeStatus: Announcing service %s.%s.%s " + "(%d)\n\n"), + (pService->m_pcName ?: m_pcHostname), pService->m_pcService, + pService->m_pcProtocol, pService->m_ProbeInformation.m_u8SentCount);); + } + else + { + pService->m_ProbeInformation.m_Timeout.resetToNeverExpires(); + DEBUG_EX_INFO( + DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Done " + "service announcing for %s.%s.%s\n\n"), + (pService->m_pcName ?: m_pcHostname), + pService->m_pcService, pService->m_pcProtocol);); } } }