odhcpd: fix infinite loop on recvmsg error - #403
Open
pandax381 wants to merge 1 commit into
Open
Conversation
When recvmsg() encounters an error other than EAGAIN, the loop previously continued indefinitely, causing an infinite loop. Fix this by also breaking out of the loop when a non-EAGAIN error occurs. Also add error logging for unexpected recvmsg failures and EINTR handling. Signed-off-by: YAMAMOTO Masaya <pandax381@gmail.com>
Author
|
@Noltari Sorry to ping you directly — would you have a moment to review this when you get a chance? Happy to make any changes if needed. Thanks! |
Author
|
@hauke Sorry to reach out directly. Would you have a moment to take a look at this, or point me to the right person to review it? Happy to make any changes if needed. Thanks! |
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.
Description
This PR fixes an issue where
odhcpdcan enter an infinite loop and consume 100% CPU whenrecvmsg()encounters an error other thanEAGAIN(such asEBADF).Background
We observed that the
odhcpdprocess was pinning a specific CPU core at 100% utilization.Investigating the running process with
stracerevealed thatrecvmsg()was being called continuously in a tight loop, relentlessly returningEBADF(Bad file descriptor) because the file descriptor had become invalid (-1).strace -f -coutput:strace -f -e trace=recvmsgoutput:The root cause was that when
recvmsg()failed with a non-EAGAINerror, the loop insideodhcpd_receive_packets()wouldcontinueindefinitely instead of breaking out.Changes
recvmsgfailure logging viaerror().EINTRby continuing the loop to prevent premature termination on signal interrupts.