diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 179a06da67..ad0da2eba0 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -2726,8 +2726,10 @@ void mdns_parse_packet(mdns_rx_packet_t * packet) if (search_result) { if (search_result->type == MDNS_TYPE_PTR) { - result->port = port; - result->hostname = strdup(name->host); + if (!result->hostname) { // assign host/port for this entry only if not previously set + result->port = port; + result->hostname = strdup(name->host); + } } else { _mdns_search_result_add_srv(search_result, name->host, port, packet->tcpip_if, packet->ip_protocol); } @@ -2814,7 +2816,10 @@ void mdns_parse_packet(mdns_rx_packet_t * packet) } } } else { - _mdns_search_result_add_txt(search_result, txt, txt_count, packet->tcpip_if, packet->ip_protocol); + _mdns_result_txt_create(data_ptr, data_len, &txt, &txt_count); + if (txt_count) { + _mdns_search_result_add_txt(search_result, txt, txt_count, packet->tcpip_if, packet->ip_protocol); + } } } else if (ours) { if (parsed_packet->questions && !parsed_packet->probe) { @@ -4009,6 +4014,8 @@ static esp_err_t _mdns_service_task_stop() vTaskDelay(10 / portTICK_PERIOD_MS); } } + vSemaphoreDelete(_mdns_service_semaphore); + _mdns_service_semaphore = NULL; return ESP_OK; } diff --git a/components/mdns/mdns_networking.c b/components/mdns/mdns_networking.c index 8450c668d6..01b6344b84 100644 --- a/components/mdns/mdns_networking.c +++ b/components/mdns/mdns_networking.c @@ -272,6 +272,7 @@ static err_t _mdns_udp_pcb_write_api(struct tcpip_api_call *api_call_msg) mdns_pcb_t * _pcb = &_mdns_server->interfaces[msg->tcpip_if].pcbs[msg->ip_protocol]; esp_err_t err = tcpip_adapter_get_netif(msg->tcpip_if, &nif); if (err) { + pbuf_free(msg->pbt); msg->err = err; return err; } diff --git a/examples/protocols/mdns/main/mdns_example_main.c b/examples/protocols/mdns/main/mdns_example_main.c index fb805545ab..bf8dd879cc 100644 --- a/examples/protocols/mdns/main/mdns_example_main.c +++ b/examples/protocols/mdns/main/mdns_example_main.c @@ -143,7 +143,7 @@ static void mdns_print_results(mdns_result_t * results){ } a = r->addr; while(a){ - if(a->addr.type == MDNS_IP_PROTOCOL_V6){ + if(a->addr.type == IPADDR_TYPE_V6){ printf(" AAAA: " IPV6STR "\n", IPV62STR(a->addr.u_addr.ip6)); } else { printf(" A : " IPSTR "\n", IP2STR(&(a->addr.u_addr.ip4)));