Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Fix task block when devif_send fails. #9423

Merged
merged 1 commit into from Jun 1, 2023

Conversation

fjpanag
Copy link
Contributor

@fjpanag fjpanag commented May 29, 2023

Summary

When a task needs to send data, a callback is allocated and the transmission is happening in a worker task through devif_send. Synchronization between the two tasks (sender & worker) is achieved by a semaphore.

If devif_send fails, this semaphore was never posted, leaving the sending task blocked indefinitely. This commit fixes this by checking the return code of netif_send, and posting this semaphore in case of failure.

Polling then stops, and execution is resumed on the sending task.

Aslo see here.

Impact

Bug fix.

Testing

Tested on a custom target based on STM32F427.
A UDP datagram is sent that it is larger than the network MTU (which will cause devif_send to fail).

Previously the sending task was blocked, but now it quickly returns with an error.

@fjpanag fjpanag force-pushed the udp_sem branch 2 times, most recently from bd51664 to 217f00b Compare May 31, 2023 19:20
When a task needs to send data, a callback is allocated and the
transmission is happening in a worker task through devif_send.
Synchronization between the two tasks (sender & worker) is
achieved by a semaphore.

If devif_send fails, this semaphore was never posted, leaving
the sending task blocked indefinitely. This commit fixes this
by checking the return code of netif_send, and posting this
semaphore in case of failure.

Polling then stops, and execution is resumed on the sending
task.
@fjpanag fjpanag marked this pull request as ready for review May 31, 2023 21:38
@fjpanag fjpanag changed the title udp: Fix block when devif_send fails. net: Fix task block when devif_send fails. May 31, 2023
@xiaoxiang781216 xiaoxiang781216 merged commit 3c54d82 into apache:master Jun 1, 2023
26 checks passed
@fjpanag fjpanag deleted the udp_sem branch June 1, 2023 09:29
Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jerpelea jerpelea added this to To-Add in Release Notes - 12.2.0 Jun 13, 2023
@jerpelea jerpelea moved this from To-Add to In Progress in Release Notes - 12.2.0 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants