rate-limiter. re-acquire lock after sleep to prevent use-after-free

I thought rust fixed this...

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I3a2fe427cdc19a6317510e8736fe46d56a6a6964
This commit is contained in:
raf 2026-02-19 00:14:57 +03:00
commit 8ed0b6fb12
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -87,13 +87,15 @@ impl RateLimiter {
if wait_time > Duration::ZERO { if wait_time > Duration::ZERO {
drop(inner); drop(inner);
tokio::time::sleep(wait_time).await; tokio::time::sleep(wait_time).await;
}
}
let mut inner = self.inner.lock().await; let mut inner = self.inner.lock().await;
let platform_requests = let platform_requests =
inner.requests.entry(platform.to_string()).or_default(); inner.requests.entry(platform.to_string()).or_default();
platform_requests.push(Instant::now()); platform_requests.push(Instant::now());
return Ok(());
}
}
platform_requests.push(Instant::now());
Ok(()) Ok(())
} }