Skip to content

net/udp: notify POLLIN after queuing read-ahead - #19960

Closed
masc2008 wants to merge 1 commit into
apache:masterfrom
masc2008:shichunma/udp-poll-readahead
Closed

masc2008 wants to merge 1 commit into
apache:masterfrom
masc2008:shichunma/udp-poll-readahead

Conversation

@masc2008

Copy link
Copy Markdown
Contributor

Summary\n- defer UDP readiness until the datagram has been queued into \n- keep and existing immediate readahead checks unchanged\n- align / readiness with what can actually consume\n\n## Problem\n currently raises as soon as is seen in the callback path. However, the datagram is only queued into UDP read-ahead later in via . That allows a waiter to wake up before has consumable data buffered.\n\n## Fix\nThis change removes the early notification from and notifies UDP poll/select waiters only after has queued the datagram into .\n\n## Validation\nThis was validated on a downstream NuttX-based target by tracing the UDP callback path and confirming the ordering changed from:\n\n- poll/select wake\n- queue into read-ahead\n\nto:\n\n- queue into read-ahead\n- poll/select wake\n\nwhich eliminated an observed early-wakeup race on a loopback UDP control socket.

UDP poll/select currently reports POLLIN as soon as UDP_NEWDATA is seen in the callback path. At that point the datagram may not yet be queued into conn->readahead, so a waiter can wake up before recvfrom() has consumable data.\n\nDefer the UDP POLLIN notification in udp_poll_eventhandler() and notify poll/select waiters only after udp_datahandler() has queued the datagram into read-ahead. This keeps poll/select readiness aligned with what recvfrom() can actually read.\n\nThis issue was observed on a loopback UDP control socket where select() woke early and recv() returned before the reply was buffered.
@github-actions github-actions Bot added Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small labels Aug 25, 2026
@masc2008
masc2008 marked this pull request as draft August 25, 2026 02:06
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis

acassis commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@masc2008 please fix the Summary, seems like your modification corrupted it:

image

@masc2008 masc2008 closed this by deleting the head repository Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants