Skip to content

Commit 5000a9a

Browse files
committed
fix(mdns): fix the logic of creating pcb for networking socket
1 parent 2646dcd commit 5000a9a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

components/mdns/mdns_networking_socket.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -352,17 +352,9 @@ static bool create_pcb(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol)
352352
}
353353
int sock = s_interfaces[tcpip_if].sock;
354354
esp_netif_t *netif = _mdns_get_esp_netif(tcpip_if);
355-
if (sock >= 0) {
356-
mdns_ip_protocol_t other_ip_proto = ip_protocol == MDNS_IP_PROTOCOL_V4 ? MDNS_IP_PROTOCOL_V6 : MDNS_IP_PROTOCOL_V4;
357-
int err = join_mdns_multicast_group(sock, netif, other_ip_proto);
358-
if (err < 0) {
359-
ESP_LOGE(TAG, "Failed to add ipv6 multicast group for protocol %d", ip_protocol);
360-
return false;
361-
}
362-
s_interfaces[tcpip_if].proto |= (other_ip_proto == MDNS_IP_PROTOCOL_V4 ? PROTO_IPV4 : PROTO_IPV6);
363-
return true;
355+
if (sock < 0) {
356+
sock = create_socket(netif);
364357
}
365-
sock = create_socket(netif);
366358
if (sock < 0) {
367359
ESP_LOGE(TAG, "Failed to create the socket!");
368360
return false;

0 commit comments

Comments
 (0)