From ba23ea4f22b5482d036706124a196fa03ef4b521 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 12 Jul 2026 01:27:46 +0900 Subject: fix(proxy-manager): correct singleton lifecycle and simplify to a plain Mutex reset() eagerly rebuilt the ProxyManager singleton immediately, capturing env vars before a caller could set them for the next request. PHP's reset() just nulls the static instance; getInstance() lazily constructs on next use. Match that so proxy env vars set after reset() are observed. get_instance() also ensured the singleton was constructed under its own lock, dropped that lock, and returned the bare Mutex; every caller then took a second, independent lock. A reset() landing in that gap would leave the caller observing None and panicking on .as_ref().unwrap(), a state the old eager-reconstructing reset() could not produce. Return the already-locked MutexGuard from get_instance() instead, so construction and use happen under one lock, and update all call sites accordingly. Holding that guard across a loop body then deadlocked in diagnose_command, since check_http_proxy transitively re-enters get_instance() via HttpDownloader -> CurlDownloader, and std::sync::Mutex is not reentrant. Re-acquire the lock fresh each iteration with a short-lived guard instead. Finally, Mutex::new is a const fn, so the OnceLock wrapper around it was unnecessary indirection; a bare static Mutex> initializes to the same state without the get_or_init/get dance. Co-Authored-By: Claude Sonnet 5 --- crates/shirabe/src/util/remote_filesystem.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/shirabe/src/util/remote_filesystem.rs') diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index fc61b16f..9b851007 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -256,7 +256,7 @@ impl RemoteFilesystem { .map_err(|e| anyhow::anyhow!(e))?; let using_proxy = { - let proxy_manager_guard = ProxyManager::get_instance().lock().unwrap(); + let proxy_manager_guard = ProxyManager::get_instance(); let proxy = proxy_manager_guard .as_ref() .expect("ProxyManager instance") -- cgit v1.3.1