aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-02 17:55:04 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-02 17:55:04 +0200
commit15d1f6516e31d20ab69569b7d6b6589f4d8f4f7b (patch)
tree32a7348e346fc6c6347a07c5a406f84e3e27bc22
parent74acb928996bcade2829c57187f35a31723be700 (diff)
downloadjellything-15d1f6516e31d20ab69569b7d6b6589f4d8f4f7b.tar
jellything-15d1f6516e31d20ab69569b7d6b6589f4d8f4f7b.tar.bz2
jellything-15d1f6516e31d20ab69569b7d6b6589f4d8f4f7b.tar.zst
async lock mutex in cache
-rw-r--r--base/src/cache.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/base/src/cache.rs b/base/src/cache.rs
index ee13b73..86c2379 100644
--- a/base/src/cache.rs
+++ b/base/src/cache.rs
@@ -46,7 +46,9 @@ where
{
let (bucket, location) = cache_location(seed);
// we need a lock even if it exists since somebody might be still in the process of writing.
- let _guard = CACHE_GENERATION_LOCKS[bucket % CACHE_GENERATION_BUCKET_COUNT].lock();
+ let _guard = CACHE_GENERATION_LOCKS[bucket % CACHE_GENERATION_BUCKET_COUNT]
+ .lock()
+ .await;
let exists = tokio::fs::try_exists(location.path())
.await
.context("unable to test for cache file existance")?;