mirror of
https://github.com/rustdesk/hbb_common.git
synced 2026-08-27 04:37:35 +00:00
4d1b9774054c9973a9a1911bcf3ac9ca90603da4
A WebRTC peer connection outlives its handle - the session cache holds a clone, and the handler that evicts it only fires on a terminal ICE state - so it has to be closed explicitly. Making that a per-exit-path obligation meant every return, break and `?` had to remember it, and the long-lived side never did: server::connection ends its ~15 exits by dropping the stream, and the transport race drops the losing result outright. Nothing warned; a missed close leaks a pc, its ICE agent and its sockets silently, and only under WebRTC. Stream is not Clone, so dropping it is the end of the transport and there is no second owner to surprise - drop-means-close is simply what the type already meant. The explicit close_webrtc() calls stay valid (they close sooner than scope end), but they are an optimization now rather than the thing correctness rests on. Also delete get_webrtc_stream(): it had no callers and was the one API handing out an owned clone that outlives its Stream, i.e. the only way to defeat this. Regression test included; it fails with the drop body emptied. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ExUfAkYbq8UC9pQCiLy8TQ
Description
No description provided
Languages
Rust
100%