Skip to content

Commit 7cdf96c

Browse files
mdns: fix missing bye packet if services removed with mdns_service_remove_all() or mdns_free()
Closes espressif/esp-idf#3660 * Original commit: espressif/esp-idf@a001998
1 parent 407875d commit 7cdf96c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

components/mdns/mdns.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,9 +1676,7 @@ static void _mdns_send_final_bye(bool include_ip)
16761676
size_t srv_count = 0;
16771677
mdns_srv_item_t * a = _mdns_server->services;
16781678
while (a) {
1679-
if (!a->service->instance) {
1680-
srv_count++;
1681-
}
1679+
srv_count++;
16821680
a = a->next;
16831681
}
16841682
if (!srv_count) {
@@ -1688,9 +1686,7 @@ static void _mdns_send_final_bye(bool include_ip)
16881686
size_t i = 0;
16891687
a = _mdns_server->services;
16901688
while (a) {
1691-
if (!a->service->instance) {
1692-
services[i++] = a;
1693-
}
1689+
services[i++] = a;
16941690
a = a->next;
16951691
}
16961692
_mdns_send_bye(services, srv_count, include_ip);
@@ -1699,7 +1695,7 @@ static void _mdns_send_final_bye(bool include_ip)
16991695
/**
17001696
* @brief Stop the responder on all services without instance
17011697
*/
1702-
static void _mdns_send_bye_all_pcbs_no_instance(void)
1698+
static void _mdns_send_bye_all_pcbs_no_instance(bool include_ip)
17031699
{
17041700
size_t srv_count = 0;
17051701
mdns_srv_item_t * a = _mdns_server->services;
@@ -1721,7 +1717,7 @@ static void _mdns_send_bye_all_pcbs_no_instance(void)
17211717
}
17221718
a = a->next;
17231719
}
1724-
_mdns_send_bye(services, srv_count, false);
1720+
_mdns_send_bye(services, srv_count, include_ip);
17251721
}
17261722

17271723
/**
@@ -3728,14 +3724,14 @@ static void _mdns_execute_action(mdns_action_t * action)
37283724
action->data.sys_event.event_id, action->data.sys_event.interface);
37293725
break;
37303726
case ACTION_HOSTNAME_SET:
3731-
_mdns_send_final_bye(true);
3727+
_mdns_send_bye_all_pcbs_no_instance(true);
37323728
free((char*)_mdns_server->hostname);
37333729
_mdns_server->hostname = action->data.hostname;
37343730
_mdns_restart_all_pcbs();
37353731

37363732
break;
37373733
case ACTION_INSTANCE_SET:
3738-
_mdns_send_bye_all_pcbs_no_instance();
3734+
_mdns_send_bye_all_pcbs_no_instance(false);
37393735
free((char*)_mdns_server->instance);
37403736
_mdns_server->instance = action->data.instance;
37413737
_mdns_restart_all_pcbs_no_instance();

0 commit comments

Comments
 (0)