Skip to content

fix(driver): robust error handling, TCP task tracking, and smol runtime fixes#795

Open
nightness wants to merge 3 commits intowebrtc-rs:masterfrom
Brainwires:fix/driver-robustness
Open

fix(driver): robust error handling, TCP task tracking, and smol runtime fixes#795
nightness wants to merge 3 commits intowebrtc-rs:masterfrom
Brainwires:fix/driver-robustness

Conversation

@nightness
Copy link
Copy Markdown

@nightness nightness commented Apr 1, 2026

Summary

Note: This PR supersedes the individual PRs #790, #791, #792, #793, and #794, consolidating all driver and runtime robustness fixes into a single reviewable change.

A collection of driver and runtime robustness fixes:

  • Transient vs fatal socket errors (better handling on socket recv error #777): EAGAIN/EWOULDBLOCK/EINTR are retried by re-queuing the recv future. Previously these caused the entire driver loop to terminate.
  • mDNS socket-creation errors: New MDNSSocketErrorHandling enum — Log (default, silent degraded mode) or Fatal (strict mode for testing). Previously any mDNS socket error terminated the connection.
  • TCP task handle tracking: Task JoinHandles are now stored and abort()ed on PeerConnection::close(), preventing task leaks.
  • Driver unwrap() removal: HashMap::insert() followed by .unwrap() replaced with entry().or_insert_with().
  • smol runtime lost-wakeup race: Replace channel-based wakeup with condvar to eliminate the TOCTOU race. Fix Mutex::lock().unwrap() panic on mutex poison.
  • Cargo.toml: Add rtc-shared dependency and tokio io-util feature required by TCP driver code.

Test plan

  • cargo test -p webrtc — all existing tests pass
  • Verify PeerConnection close does not leak tasks
  • Verify connection survives transient EAGAIN errors on UDP recv

🤖 Generated with Claude Code

nightness and others added 3 commits April 1, 2026 11:46
…me fixes

- fix(driver): distinguish transient vs fatal UDP socket recv errors (webrtc-rs#777)
  EAGAIN/EWOULDBLOCK/EINTR are re-queued; fatal errors abort and return
- fix(driver): configurable mDNS socket-creation error handling
  New `MDNSSocketErrorHandling` enum: Log (default) or Fatal
- fix(driver): track TCP task handles and abort on shutdown; add lifecycle logging
  Prevents task leaks on PeerConnection close
- fix(driver): remove .unwrap() after guaranteed HashMap entry insert
  Replaced with `entry().or_insert_with()` pattern
- fix(runtime/smol): eliminate lost-wakeup race and mutex-poison panic
  Use condvar-based wakeup instead of channel; fix Mutex unwrap on poison

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… new example entries

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant