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:
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user