Skip to content

Commit e2a36ed

Browse files
authored
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.
1 parent d44c3f4 commit e2a36ed

File tree

1 file changed

+58
-44
lines changed

1 file changed

+58
-44
lines changed

Diff for: libraries/ESP8266mDNS/src/LEAmDNS_Control.cpp

+58-44
Original file line numberDiff line numberDiff line change
@@ -1395,11 +1395,18 @@ namespace MDNSImplementation
13951395
{
13961396
if ((bResult = _sendHostProbe()))
13971397
{
1398-
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1399-
PSTR("[MDNSResponder] _updateProbeStatus: Did sent host probe\n\n")););
1400-
m_HostProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY);
1401-
++m_HostProbeInformation.m_u8SentCount;
1398+
DEBUG_EX_INFO(
1399+
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Did sent "
1400+
"host probe to all links \n\n")););
1401+
}
1402+
else
1403+
{
1404+
DEBUG_EX_INFO(
1405+
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Did not "
1406+
"sent host probe to all links\n\n")););
14021407
}
1408+
m_HostProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY);
1409+
++m_HostProbeInformation.m_u8SentCount;
14031410
}
14041411
else // Probing finished
14051412
{
@@ -1422,23 +1429,22 @@ namespace MDNSImplementation
14221429
else if ((ProbingStatus_Done == m_HostProbeInformation.m_ProbingStatus)
14231430
&& (m_HostProbeInformation.m_Timeout.expired()))
14241431
{
1425-
if ((bResult = _announce(true, false))) // Don't announce services here
1426-
{
1427-
++m_HostProbeInformation.m_u8SentCount;
1432+
_announce(true, false); // Don't announce services here
14281433

1429-
if (MDNS_ANNOUNCE_COUNT > m_HostProbeInformation.m_u8SentCount)
1430-
{
1431-
m_HostProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY);
1432-
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1433-
PSTR("[MDNSResponder] _updateProbeStatus: Announcing host (%d).\n\n"),
1434-
m_HostProbeInformation.m_u8SentCount););
1435-
}
1436-
else
1437-
{
1438-
m_HostProbeInformation.m_Timeout.resetToNeverExpires();
1439-
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1440-
PSTR("[MDNSResponder] _updateProbeStatus: Done host announcing.\n\n")););
1441-
}
1434+
++m_HostProbeInformation.m_u8SentCount;
1435+
1436+
if (MDNS_ANNOUNCE_COUNT > m_HostProbeInformation.m_u8SentCount)
1437+
{
1438+
m_HostProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY);
1439+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1440+
PSTR("[MDNSResponder] _updateProbeStatus: Announcing host (%d).\n\n"),
1441+
m_HostProbeInformation.m_u8SentCount););
1442+
}
1443+
else
1444+
{
1445+
m_HostProbeInformation.m_Timeout.resetToNeverExpires();
1446+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1447+
PSTR("[MDNSResponder] _updateProbeStatus: Done host announcing.\n\n")););
14421448
}
14431449
}
14441450

@@ -1464,12 +1470,21 @@ namespace MDNSImplementation
14641470
if ((bResult = _sendServiceProbe(*pService)))
14651471
{
14661472
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1467-
PSTR("[MDNSResponder] _updateProbeStatus: Did sent service probe "
1473+
PSTR("[MDNSResponder] _updateProbeStatus: Did sent service probe to "
1474+
"all links "
14681475
"(%u)\n\n"),
14691476
(pService->m_ProbeInformation.m_u8SentCount + 1)););
1470-
pService->m_ProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY);
1471-
++pService->m_ProbeInformation.m_u8SentCount;
14721477
}
1478+
else
1479+
{
1480+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1481+
PSTR("[MDNSResponder] _updateProbeStatus: Did not sent service probe "
1482+
"to all links"
1483+
"(%u)\n\n"),
1484+
(pService->m_ProbeInformation.m_u8SentCount + 1)););
1485+
}
1486+
pService->m_ProbeInformation.m_Timeout.reset(MDNS_PROBE_DELAY);
1487+
++pService->m_ProbeInformation.m_u8SentCount;
14731488
}
14741489
else // Probing finished
14751490
{
@@ -1495,28 +1510,27 @@ namespace MDNSImplementation
14951510
else if ((ProbingStatus_Done == pService->m_ProbeInformation.m_ProbingStatus)
14961511
&& (pService->m_ProbeInformation.m_Timeout.expired()))
14971512
{
1498-
if ((bResult = _announceService(*pService))) // Announce service
1499-
{
1500-
++pService->m_ProbeInformation.m_u8SentCount;
1513+
_announceService(*pService); // Announce service
15011514

1502-
if (MDNS_ANNOUNCE_COUNT > pService->m_ProbeInformation.m_u8SentCount)
1503-
{
1504-
pService->m_ProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY);
1505-
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1506-
PSTR("[MDNSResponder] _updateProbeStatus: Announcing service %s.%s.%s "
1507-
"(%d)\n\n"),
1508-
(pService->m_pcName ?: m_pcHostname), pService->m_pcService,
1509-
pService->m_pcProtocol, pService->m_ProbeInformation.m_u8SentCount););
1510-
}
1511-
else
1512-
{
1513-
pService->m_ProbeInformation.m_Timeout.resetToNeverExpires();
1514-
DEBUG_EX_INFO(
1515-
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Done "
1516-
"service announcing for %s.%s.%s\n\n"),
1517-
(pService->m_pcName ?: m_pcHostname),
1518-
pService->m_pcService, pService->m_pcProtocol););
1519-
}
1515+
++pService->m_ProbeInformation.m_u8SentCount;
1516+
1517+
if (MDNS_ANNOUNCE_COUNT > pService->m_ProbeInformation.m_u8SentCount)
1518+
{
1519+
pService->m_ProbeInformation.m_Timeout.reset(MDNS_ANNOUNCE_DELAY);
1520+
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(
1521+
PSTR("[MDNSResponder] _updateProbeStatus: Announcing service %s.%s.%s "
1522+
"(%d)\n\n"),
1523+
(pService->m_pcName ?: m_pcHostname), pService->m_pcService,
1524+
pService->m_pcProtocol, pService->m_ProbeInformation.m_u8SentCount););
1525+
}
1526+
else
1527+
{
1528+
pService->m_ProbeInformation.m_Timeout.resetToNeverExpires();
1529+
DEBUG_EX_INFO(
1530+
DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] _updateProbeStatus: Done "
1531+
"service announcing for %s.%s.%s\n\n"),
1532+
(pService->m_pcName ?: m_pcHostname),
1533+
pService->m_pcService, pService->m_pcProtocol););
15201534
}
15211535
}
15221536
}

0 commit comments

Comments
 (0)