-
Notifications
You must be signed in to change notification settings - Fork 13.3k
LEAmDNS_Fixes_1_3 #5689
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
LEAmDNS_Fixes_1_3 #5689
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From gitter discussion:
@LaborEtArs with the UdpContext check, isn't the new hostname passed as arg to begin ignored?
Should the begin() implementation look something like this (unoptimized for the logic tree)?:
bool MDNSResponder::begin(const char* p_pcHostname) {
bool bResult = (0 != m_pcHostname);
if (0 == m_pUDPContext) {
if (_setHostname(p_pcHostname)) {
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& pEvent) {
(void) pEvent;
_restart();
});
m_DisconnectedHandler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected& pEvent) {
(void) pEvent;
_restart();
});
bResult = _restart();
}
} else {
if (_setHostname(p_pcHostname)) {
bResult = _restart();
}
DEBUG_EX_INFO(DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: Ignoring multiple calls (Ignored host domain: '%s')!\n"), (p_pcHostname ?: "-")););
}
DEBUG_EX_ERR(if (!bResult) { DEBUG_OUTPUT.printf_P(PSTR("[MDNSResponder] begin: FAILED for '%s'!\n"), (p_pcHostname ?: "-")); } );
return bResult;
}
Is the use of bool bResult = (0 != m_pcHostname); correct?
@devyte : You're right, the code was TOO 'quick and dirty', but I don't like your proposed code too, When 'begin()' was called once, another call to begin() should fail. At least it shouldn't change something silently (as it would, if OTA will be initialized after mDNS by the user). Unfortunately I can't change the code here (webeditor?, maybe only for branch owners? Maybe not with IE...?)... |
Updated (and included the 'schedule_function(std::bind(&MDNSResponder::_restart, this));' to avoid calling _restart() in SYS context. |
Re-Fix 'avoid multiple initialization' code in LEAmDNSResponder::begin()