resilience: isolate per-connection panics in the plaintext reactor (catch_unwind read/write -> drop just that conn) and log worker-thread panics instead of vanishing silently
This commit is contained in:
parent
145a01b2c2
commit
e91b64a4db
2 changed files with 24 additions and 4 deletions
|
|
@ -479,8 +479,14 @@ impl Server {
|
|||
let tx = self.event_tx.clone();
|
||||
std::thread::spawn(move || {
|
||||
let _guard = Guard; // decrements even on panic
|
||||
let ev = f();
|
||||
let _ = tx.send(ev);
|
||||
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)) {
|
||||
Ok(ev) => {
|
||||
let _ = tx.send(ev);
|
||||
}
|
||||
// a panic here can't reach the core (we don't know which Event to send);
|
||||
// log it so a stuck request is diagnosable instead of silent.
|
||||
Err(_) => eprintln!("[worker] a background crypto/http task panicked; its request was dropped"),
|
||||
}
|
||||
});
|
||||
true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue