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:
Andy Dixon
2026-10-12 09:07:32 +01:00
parent afec95bb36
commit f09300fd95
28 changed files with 252 additions and 221 deletions
+4 -4
View File
@@ -3,12 +3,12 @@
use crate::Result;
use crate::models::Time;
use parking_lot::Mutex;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fs::File;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use std::time::Instant;
pub const EVENT_OUTPUT: &str = "o";
@@ -156,7 +156,7 @@ impl Recorder {
}
fn write_event(&self, kind: &str, data: &[u8]) {
let mut g = self.inner.lock().unwrap();
let mut g = self.inner.lock();
if g.closed || g.file.is_none() {
return;
}
@@ -177,7 +177,7 @@ impl Recorder {
/// Flushes and closes the file. Idempotent.
pub fn close(&self) -> Result<()> {
let mut g = self.inner.lock().unwrap();
let mut g = self.inner.lock();
if g.closed {
return Ok(());
}
@@ -198,7 +198,7 @@ impl Recorder {
}
pub fn event_count(&self) -> usize {
self.inner.lock().unwrap().event_count
self.inner.lock().event_count
}
}