From 79b8e38dd7e65531c9c5e4c7900f4d03ecb2ff12 Mon Sep 17 00:00:00 2001 From: varex83 Date: Fri, 27 Oct 2023 13:33:06 +0300 Subject: [PATCH] fix double mutex call, that could lead to race condition --- api/src/rate_limiter.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/api/src/rate_limiter.rs b/api/src/rate_limiter.rs index bbc1eb8b..573163d3 100644 --- a/api/src/rate_limiter.rs +++ b/api/src/rate_limiter.rs @@ -88,7 +88,7 @@ impl RateLimiter { fn purge(&self) -> Result<()> { let now = timestamp(); - let last_purge = self + let mut last_purge = self .last_purge .lock() .map_err(|_| ApiError::MutexUnlockError)?; @@ -98,11 +98,6 @@ impl RateLimiter { self.call_queue.clear(); - let mut last_purge = self - .last_purge - .lock() - .map_err(|_| ApiError::MutexUnlockError)?; - *last_purge = now; }