Skip to content

Commit e4a5059

Browse files
committed
refactor: identify deadlock
1 parent aa4d51b commit e4a5059

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/backend/mod.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub trait Backend: Debug + Send + Sync {
199199

200200
fn list_remote_versions(&self) -> eyre::Result<Vec<String>> {
201201
self.get_remote_version_cache()
202+
// TODO: fix deadlock
202203
.get_or_try_init(|| {
203204
trace!("Listing remote versions for {}", self.ba().to_string());
204205
match versions_host::list_versions(self.ba()) {
@@ -630,23 +631,24 @@ pub trait Backend: Debug + Send + Sync {
630631
static REMOTE_VERSION_CACHE: Lazy<Mutex<HashMap<String, Arc<VersionCacheManager>>>> =
631632
Lazy::new(|| Mutex::new(HashMap::new()));
632633

633-
// REMOTE_VERSION_CACHE
634-
// .lock()
635-
// .unwrap()
636-
// .entry(self.ba().full())
637-
// .or_insert_with(|| {
638-
let mut cm =
639-
CacheManagerBuilder::new(self.ba().cache_path.join("remote_versions.msgpack.z"))
634+
REMOTE_VERSION_CACHE
635+
.lock()
636+
.unwrap()
637+
.entry(self.ba().full())
638+
.or_insert_with(|| {
639+
let mut cm = CacheManagerBuilder::new(
640+
self.ba().cache_path.join("remote_versions.msgpack.z"),
641+
)
640642
.with_fresh_duration(SETTINGS.fetch_remote_versions_cache());
641-
if let Some(plugin_path) = self.plugin().map(|p| p.path()) {
642-
cm = cm
643-
.with_fresh_file(plugin_path.clone())
644-
.with_fresh_file(plugin_path.join("bin/list-all"))
645-
}
643+
if let Some(plugin_path) = self.plugin().map(|p| p.path()) {
644+
cm = cm
645+
.with_fresh_file(plugin_path.clone())
646+
.with_fresh_file(plugin_path.join("bin/list-all"))
647+
}
646648

647-
Arc::new(cm.build())
648-
// })
649-
// .clone()
649+
Arc::new(cm.build())
650+
})
651+
.clone()
650652
}
651653

652654
fn verify_checksum(

0 commit comments

Comments
 (0)