Home

dev / openkara

publicthedavidweng/OpenKara· sync paused
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix(remote): replace park-thread pin leak with RemoteStreamingRuntime

2 months ago

17602c3
Authored
Davy7/20/2026, 10:40:46 PM
The reconnect handler was leaking a detached thread::park() thread for
each cache-fast-path reconnect to keep the cache pin guard alive. This
caused permanent thread and pin accumulation over long sessions.

Introduce RemoteStreamingRuntime — an RAII container for the cache pin
guard and fetch event receiver. The re_resolve closure packages them
into the runtime and returns it via ReresolvedSource/ReconnectSuccess.
The caller (attempt_remote_reconnect) spawns a fetch event listener
thread that owns the runtime. For sources with a fetch event rx, the
thread blocks on the rx and exits when it closes (source dropped on
skip/stop/replace), dropping the pin guard. For cache-fast-path sources
(no rx), the thread polls the request_id staleness check and exits when
the song is no longer current.

This ensures the pin guard is always dropped when playback moves on,
unpinning the cache entry for LRU eviction.

Parent008835e

3 files changed
  • src-tauri/src/remote/fault_injection.rs+6−2
  • src-tauri/src/services/playback.rs+130−95
  • src-tauri/src/services/reconnect.rs+54−0