Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Cap simultaneous image fetches

Limit concurrent Reqwest requests with a Tokio Semaphore to avoid
exhausting
file descriptors when many album/artist images are requested. Set the
cap to
MAX_CONCURRENT_REQUESTS=8 and pool_max_idle_per_host=4.

+13 -4
+13 -4
gpui/src/http_client.rs
··· 3 3 use http::HeaderValue; 4 4 use std::sync::Arc; 5 5 use tokio::runtime::Handle; 6 + use tokio::sync::Semaphore; 7 + 8 + // Cap simultaneous image fetches so rockboxd doesn't exhaust its file descriptor limit 9 + // when a large album/artist grid triggers many concurrent requests. 10 + const MAX_CONCURRENT_REQUESTS: usize = 8; 6 11 7 12 pub struct ReqwestHttpClient { 8 13 client: reqwest::Client, 9 14 handle: Handle, 15 + semaphore: Arc<Semaphore>, 10 16 } 11 17 12 18 impl ReqwestHttpClient { 13 19 pub fn new(handle: Handle) -> Arc<Self> { 14 20 Arc::new(Self { 15 - client: reqwest::Client::new(), 21 + client: reqwest::Client::builder() 22 + .pool_max_idle_per_host(4) 23 + .build() 24 + .unwrap_or_default(), 16 25 handle, 26 + semaphore: Arc::new(Semaphore::new(MAX_CONCURRENT_REQUESTS)), 17 27 }) 18 28 } 19 29 } ··· 35 45 &self, 36 46 req: Request<AsyncBody>, 37 47 ) -> BoxFuture<'static, anyhow::Result<Response<AsyncBody>>> { 38 - // Bridge tokio (reqwest) and GPUI's smol executor via a tokio oneshot channel. 39 - // tokio::sync::oneshot::Receiver implements Future using standard Waker, so it can 40 - // be awaited from any executor context — including GPUI's smol background executor. 41 48 let (tx, rx) = tokio::sync::oneshot::channel::<anyhow::Result<Response<AsyncBody>>>(); 42 49 let client = self.client.clone(); 50 + let semaphore = self.semaphore.clone(); 43 51 self.handle.spawn(async move { 52 + let _permit = semaphore.acquire().await; 44 53 let _ = tx.send(do_fetch(client, req).await); 45 54 }); 46 55 Box::pin(async move {