[mdns]: Minor corrections to mdns socket layer#1008
Open
david-cermak wants to merge 1 commit intoespressif:masterfrom
Open
[mdns]: Minor corrections to mdns socket layer#1008david-cermak wants to merge 1 commit intoespressif:masterfrom
david-cermak wants to merge 1 commit intoespressif:masterfrom
Conversation
2b62282 to
37b8a7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mDNS socket layer cleanup (mdns_networking_socket.c)
This note documents follow-up fixes applied to the BSD-socket based mDNS networking backend (
components/mdns/mdns_networking_socket.c).1. Deterministic RX task shutdown (remove fixed delay)
Problem:
mdns_priv_if_deinit()previously stopped the RX task with a fixedvTaskDelay(500ms), which is not a deterministic synchronization mechanism (task may still be running; rapid re-init can race).Correction:
s_sock_recv_task_handle.s_sock_recv_task_exit_sem.s_run_sock_recv_task = falses_sock_recv_task_exit_sem(bounded wait)xSemaphoreGive(s_sock_recv_task_exit_sem)immediately beforevTaskDelete(NULL).2. Improve select()/recvfrom() unblocking during socket close
Problem: Closing a socket from another task does not reliably and immediately unblock a thread blocked in
select()/recvfrom()on all stacks/ports.Correction:
delete_socket()now performs a best-effortshutdown(sock, SHUT_RDWR)prior toclose(sock)to encourage prompt unblocking.3. recvfrom() error handling (avoid repeated error/log-spin)
Problem: A
recvfrom()error only broke out of the inner per-interface loop, leaving the RX task alive and potentially re-hitting the same invalid socket each select cycle.Correction:
recvfrom()failure:WARNdelete_socket(sock))s_interfaces[tcpip_if].sock = -1s_interfaces[tcpip_if].proto = 0select()now ignoresEINTRby retrying the loop.4. Multicast group join failure must not mark protocol as ready
Problem:
create_pcb()set the per-interface protocol bit even whenjoin_mdns_multicast_group()failed, resulting in an interface being treated as ready for that protocol while multicast RX might be non-functional.Correction:
join_mdns_multicast_group()fails,create_pcb()returnsfalseand does not set the protocol bit.5. Normalize socket close paths
Problem: Socket cleanup was split between direct
close()calls anddelete_socket(), risking divergence ifdelete_socket()gains additional behavior.Correction:
create_socket()error path now callsdelete_socket(sock)instead ofclose(sock).