Skip to content

Commit

Permalink
mDNS timeout: use real type (#8394)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v authored Dec 2, 2021
1 parent 26103a5 commit d18cbfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion libraries/ESP8266mDNS/src/LEAmDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,8 @@ class MDNSResponder
esp8266::polledTimeout::oneShotMs m_TTLTimeout;
timeoutLevel_t m_timeoutLevel;

using timeoutBase = decltype(m_TTLTimeout);

stcTTL(void);
bool set(uint32_t p_u32TTL);

Expand All @@ -1039,7 +1041,7 @@ class MDNSResponder
bool prepareDeletion(void);
bool finalTimeoutLevel(void) const;

unsigned long timeout(void) const;
timeoutBase::timeType timeout(void) const;
};
#ifdef MDNS_IP4_SUPPORT
/**
Expand Down
11 changes: 4 additions & 7 deletions libraries/ESP8266mDNS/src/LEAmDNS_Structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,22 +1663,19 @@ bool MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::finalTimeoutLevel(vo
/*
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%
{
timeout = (m_u32TTL * 800L); // to milliseconds
return (m_u32TTL * 800L); // to milliseconds
}
else if ((TIMEOUTLEVEL_BASE < m_timeoutLevel) && // >80% AND
(TIMEOUTLEVEL_FINAL >= m_timeoutLevel)) // <= 100%
{

timeout = (m_u32TTL * 50L);
return (m_u32TTL * 50L);
} // else: invalid
return timeout;
return MDNSResponder::stcMDNSServiceQuery::stcAnswer::stcTTL::timeoutBase::neverExpires;
}


Expand Down

0 comments on commit d18cbfb

Please sign in to comment.