Handle device EOF and I/O errors in the main event loop #88 - #93
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Existing stream tasks are not notified or terminated on EOF or read errors, which can leave accepted streams waiting indefinitely.
Pull request overview
Handles device EOF and I/O errors in the IP stack’s main event loop.
Changes:
- Treats zero-byte reads as EOF.
- Logs and propagates device read errors.
- Adds EOF regression coverage.
File summaries
| File | Summary |
|---|---|
src/lib.rs |
Updates event-loop termination handling and adds EOF coverage. |
Review details
Suppressed comments (2)
src/lib.rs:326
- Returning here drops the
sessionsmap, but it does not stop already accepted stream tasks.sessionsonly owns a cloned packet sender, while eachIpStackTcpStream/IpStackUdpStreamretains another sender for its receive channel, so those tasks are not notified that the device has ended; an application awaiting an existing stream can remain pending indefinitely after EOF (and after a read error). Propagate a stack-shutdown signal to each session or explicitly abort/close the session tasks before returning.
Ok(0) => {
log::info!("Device EOF, stopping IP stack");
return Ok(());
src/lib.rs:331
- This error path has the same lifecycle problem as the EOF path: returning from the loop drops the event loop and its
sessionssenders, but does not notify or terminate existing stream tasks. A stream already returned byaccept()can therefore wait forever after a device read error; use the same session-shutdown mechanism here before returning.
Err(e) => {
log::error!("Device read error: {e}");
return Err(e.into());
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
#88