fix: a panic on one thread no longer takes the whole app down
Every shared lock was std::sync::Mutex with lock().unwrap() (~150 sites), so a panic in any session's reader or callback poisoned the lock and the next UI frame panicked too, dropping every open session. Locks are now parking_lot::Mutex (no poisoning; already in the dependency tree), and a panic hook reports worker panics as an error toast instead of the session silently stopping (F3, F4).
This commit is contained in:
@@ -11,9 +11,10 @@ use nexus_core::clients::serial;
|
||||
use nexus_core::keyfiles;
|
||||
use nexus_core::models::*;
|
||||
use nexus_core::validation::{ValidationError, validate_profile};
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
|
||||
type KeyChecks = HashMap<String, Result<&'static str, &'static str>>;
|
||||
|
||||
@@ -184,7 +185,7 @@ impl ProfileEditor {
|
||||
/// Drawn inside the right dock while open.
|
||||
pub fn ui(&mut self, ui: &mut Ui, s: &mut Shared) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
if let Some(r) = self.test.lock().unwrap().take() {
|
||||
if let Some(r) = self.test.lock().take() {
|
||||
self.testing = false;
|
||||
match r {
|
||||
Ok(ms) => s.success(format!("Reachable — {ms} ms")),
|
||||
@@ -336,7 +337,7 @@ impl ProfileEditor {
|
||||
let (slot, svc, ctx) = (self.test.clone(), s.svc.clone(), s.ctx.clone());
|
||||
std::thread::spawn(move || {
|
||||
let r = svc.test_connection(&host, port).map_err(|e| e.to_string());
|
||||
*slot.lock().unwrap() = Some(r);
|
||||
*slot.lock() = Some(r);
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user