Skip to content

Handle device EOF and I/O errors in the main event loop #88 - #93

Merged
SajjadPourali merged 1 commit into
mainfrom
handle-device-eof-fix
Sep 16, 2026
Merged

SajjadPourali merged 1 commit into
mainfrom
handle-device-eof-fix

Conversation

@SajjadPourali

@SajjadPourali SajjadPourali commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

#88

Copilot AI lite review requested due to automatic review settings September 16, 2026 03:35
@SajjadPourali
SajjadPourali merged commit 6489fcf into main Sep 16, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 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 sessions map, but it does not stop already accepted stream tasks. sessions only owns a cloned packet sender, while each IpStackTcpStream/IpStackUdpStream retains 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 sessions senders, but does not notify or terminate existing stream tasks. A stream already returned by accept() 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.

@SajjadPourali
SajjadPourali deleted the handle-device-eof-fix branch September 16, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants