2 months ago
17602c3The 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