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:
parent
7ee9ee1159
commit
8ed0b6fb12
1 changed files with 5 additions and 3 deletions
|
|
@ -87,12 +87,14 @@ impl RateLimiter {
|
|||
if wait_time > Duration::ZERO {
|
||||
drop(inner);
|
||||
tokio::time::sleep(wait_time).await;
|
||||
let mut inner = self.inner.lock().await;
|
||||
let platform_requests =
|
||||
inner.requests.entry(platform.to_string()).or_default();
|
||||
platform_requests.push(Instant::now());
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let mut inner = self.inner.lock().await;
|
||||
let platform_requests =
|
||||
inner.requests.entry(platform.to_string()).or_default();
|
||||
platform_requests.push(Instant::now());
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue