context: fix deadlock and panics when resolving parented contexts
set_current held the config RwLock for writing across make_context, which for a context with a parent re-entered the same lock through Context::new's global-manager lookup, deadlocking 'pkh context use'. Context building is now lock-free by construction: make_context resolves parent chains against a snapshot map (also rejecting parent cycles), and neither set_current nor remove_context holds a guard while building a Context. A corrupt contexts.json no longer aborts every command at manager init: load falls back to the default local-only config, backs the corrupt file up to contexts.json.bak so a later save cannot silently destroy it, and a dangling current/parent context falls back to local with an error log instead of panicking.
This commit is contained in:
+2
-2
@@ -397,7 +397,7 @@ mod tests {
|
||||
log::info!("Successfully pulled package {}", package);
|
||||
|
||||
// Create a fresh local context for this test
|
||||
let ctx = Arc::new(Context::new(crate::context::ContextConfig::Local));
|
||||
let ctx = Arc::new(Context::new(crate::context::ContextConfig::Local).unwrap());
|
||||
|
||||
// Change directory to the package directory
|
||||
let cwd =
|
||||
@@ -578,7 +578,7 @@ mod tests {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let pkg_dir = create_indep_cross_test_source(temp_dir.path());
|
||||
|
||||
let ctx = Arc::new(Context::new(crate::context::ContextConfig::Local));
|
||||
let ctx = Arc::new(Context::new(crate::context::ContextConfig::Local).unwrap());
|
||||
|
||||
crate::deb::build_binary_package(
|
||||
Some("arm64"),
|
||||
|
||||
Reference in New Issue
Block a user