refactor: replace lock unwraps with poison-aware helpers

Add SoulseekRs::LockPoisoned variant and a small RwLockExt/MutexExt
helper module exposing read_safe/write_safe/lock_safe that map
PoisonError to that variant. Walk every non-test lock acquisition
across client, peer/server actors, peer registry, listener and the
thread pool: propagate via ? where the function returns Result, log
and degrade to a sensible default (return early, false, None, empty)
where it does not. Client::connect now returns Result so the CLI can
surface the failure instead of panicking.
This commit is contained in:
michel
2026-04-26 12:32:46 +02:00
parent e1ee3ac493
commit 2722552e35
10 changed files with 473 additions and 164 deletions
+5
View File
@@ -18,6 +18,8 @@ pub enum SoulseekRs {
NotConnected,
/// Compression/decompression error
CompressionError(String),
/// A lock was poisoned by a panic in another thread
LockPoisoned,
}
impl fmt::Display for SoulseekRs {
@@ -39,6 +41,9 @@ impl fmt::Display for SoulseekRs {
SoulseekRs::CompressionError(msg) => {
write!(f, "Compression error: {}", msg)
}
SoulseekRs::LockPoisoned => {
write!(f, "Lock poisoned by panicking thread")
}
}
}
}