@@ -2741,8 +2741,10 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
27412741
27422742 if (search_result ) {
27432743 if (search_result -> type == MDNS_TYPE_PTR ) {
2744- result -> port = port ;
2745- result -> hostname = strdup (name -> host );
2744+ if (!result -> hostname ) { // assign host/port for this entry only if not previously set
2745+ result -> port = port ;
2746+ result -> hostname = strdup (name -> host );
2747+ }
27462748 } else {
27472749 _mdns_search_result_add_srv (search_result , name -> host , port , packet -> tcpip_if , packet -> ip_protocol );
27482750 }
@@ -2829,7 +2831,10 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
28292831 }
28302832 }
28312833 } else {
2832- _mdns_search_result_add_txt (search_result , txt , txt_count , packet -> tcpip_if , packet -> ip_protocol );
2834+ _mdns_result_txt_create (data_ptr , data_len , & txt , & txt_count );
2835+ if (txt_count ) {
2836+ _mdns_search_result_add_txt (search_result , txt , txt_count , packet -> tcpip_if , packet -> ip_protocol );
2837+ }
28332838 }
28342839 } else if (ours ) {
28352840 if (parsed_packet -> questions && !parsed_packet -> probe ) {
@@ -4015,8 +4020,6 @@ static esp_err_t _mdns_service_task_stop()
40154020 MDNS_SERVICE_LOCK ();
40164021 _mdns_stop_timer ();
40174022 MDNS_SERVICE_UNLOCK ();
4018- vSemaphoreDelete (_mdns_service_semaphore );
4019- _mdns_service_semaphore = NULL ;
40204023 if (_mdns_service_task_handle ) {
40214024 mdns_action_t action ;
40224025 mdns_action_t * a = & action ;
@@ -4029,6 +4032,8 @@ static esp_err_t _mdns_service_task_stop()
40294032 vTaskDelay (10 / portTICK_PERIOD_MS );
40304033 }
40314034 }
4035+ vSemaphoreDelete (_mdns_service_semaphore );
4036+ _mdns_service_semaphore = NULL ;
40324037 return ESP_OK ;
40334038}
40344039
0 commit comments