Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mDNS timeout: use real type #8394

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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