1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-27 21:16:50 +03:00

mDNS timeout: use real type (#8394)

This commit is contained in:
david gauchard 2021-12-02 23:38:35 +01:00 committed by GitHub
parent 26103a5827
commit d18cbfb07d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -1030,6 +1030,8 @@ protected:
esp8266::polledTimeout::oneShotMs m_TTLTimeout; esp8266::polledTimeout::oneShotMs m_TTLTimeout;
timeoutLevel_t m_timeoutLevel; timeoutLevel_t m_timeoutLevel;
using timeoutBase = decltype(m_TTLTimeout);
stcTTL(void); stcTTL(void);
bool set(uint32_t p_u32TTL); bool set(uint32_t p_u32TTL);
@ -1039,7 +1041,7 @@ protected:
bool prepareDeletion(void); bool prepareDeletion(void);
bool finalTimeoutLevel(void) const; bool finalTimeoutLevel(void) const;
unsigned long timeout(void) const; timeoutBase::timeType timeout(void) const;
}; };
#ifdef MDNS_IP4_SUPPORT #ifdef MDNS_IP4_SUPPORT
/** /**

View File

@ -1663,22 +1663,19 @@ bool MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::finalTimeoutLevel(vo
/* /*
MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout
*/ */
unsigned long MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout(void) const MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeoutBase::timeType MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeout(void) const
{ {
unsigned long timeout = esp8266::polledTimeout::oneShotMs::neverExpires;
if (TIMEOUTLEVEL_BASE == m_timeoutLevel) // 80% if (TIMEOUTLEVEL_BASE == m_timeoutLevel) // 80%
{ {
timeout = (m_u32TTL * 800L); // to milliseconds return (m_u32TTL * 800L); // to milliseconds
} }
else if ((TIMEOUTLEVEL_BASE < m_timeoutLevel) && // >80% AND else if ((TIMEOUTLEVEL_BASE < m_timeoutLevel) && // >80% AND
(TIMEOUTLEVEL_FINAL >= m_timeoutLevel)) // <= 100% (TIMEOUTLEVEL_FINAL >= m_timeoutLevel)) // <= 100%
{ {
timeout = (m_u32TTL * 50L); return (m_u32TTL * 50L);
} // else: invalid } // else: invalid
return timeout; return MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeoutBase::neverExpires;
} }