Skip to content

Conversation

@13627105546
Copy link
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

This PR addresses an issue where usrsock repeatedly sets POLLIN events when the network interface is down and a client attempts to connect, leading to an infinite loop or abnormal EPIPE setting.

The changes involve:

  1. Clearing the USRSOCK_EVENT_RECVFROM_AVAIL flag when a remote connection is closed during accept.
  2. Checking the USRSOCK_EVENT_RECVFROM_AVAIL flag before setting POLLIN in both poll_event and usrsock_pollsetup.

By ensuring POLLIN is only set when data is actually available (indicated by the flag), we prevent the repetitive POLLIN triggering that causes the EPIPE loop.

Impact

  • Impact on user: Fixes a potential system hang or high CPU usage loop in usrsock when handling connection attempts on a down interface.
  • Backward compatibility: Yes.
  • New feature: No, bug fix.

Testing

  • Verification:
    • Verified that POLLIN is no longer repeatedly set when the remote closes the connection during an accept sequence on a down interface.
    • Passed tools/checkpatch.sh.

Clear USRSOCK_EVENT_RECVFROM_AVAIL flag when remote closes connection during accept to prevent repeated POLLIN events and EPIPE loop.

Signed-off-by: daichuan <[email protected]>
@github-actions github-actions bot added Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small labels Jan 14, 2026
@jerpelea jerpelea changed the title usrsock: Fix EPIPE loop by clearing POLLIN on remote close net/usrsock: Fix EPIPE loop by clearing POLLIN on remote close Jan 14, 2026
@13627105546
Copy link
Contributor Author

This commit must be applied after apache/nuttx-apps#3340.

@xiaoxiang781216
Copy link
Contributor

@13627105546 please rebase your patch to the last master which fix the ci break.

@13627105546 13627105546 force-pushed the topic/usrsock-poll-fix branch from c0f8f68 to 9b52cc5 Compare January 20, 2026 03:50
In usrsock_pollsetup, only set POLLIN if USRSOCK_EVENT_RECVFROM_AVAIL is set when remote is closed, avoiding invalid POLLIN events.

Signed-off-by: daichuan <[email protected]>
@13627105546 13627105546 force-pushed the topic/usrsock-poll-fix branch from 9b52cc5 to 5a8fc38 Compare January 20, 2026 09:55
@xiaoxiang781216 xiaoxiang781216 merged commit a82ee60 into apache:master Jan 20, 2026
40 checks passed
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.

3 participants