summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/os_input_output.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-09-02 15:30:43 +0200
committerGitHub <noreply@github.com>2022-09-02 15:30:43 +0200
commitd68d407d26edadda032fcce620316708bd9b3985 (patch)
tree647786afce4939bc4d9c6a835ef3e35800077d44 /zellij-server/src/os_input_output.rs
parent93f0f783b8cde5d0a3217a14466a0452c962e322 (diff)
fix(router): gracefully handle client crashes (#1710)
* fix(router): gracefully handle client crashes * style(comments): remove unused
Diffstat (limited to 'zellij-server/src/os_input_output.rs')
-rw-r--r--zellij-server/src/os_input_output.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs
index 31f1780b8..8bd62a219 100644
--- a/zellij-server/src/os_input_output.rs
+++ b/zellij-server/src/os_input_output.rs
@@ -316,7 +316,11 @@ pub trait ServerOsApi: Send + Sync {
fn force_kill(&self, pid: Pid) -> Result<(), nix::Error>;
/// Returns a [`Box`] pointer to this [`ServerOsApi`] struct.
fn box_clone(&self) -> Box<dyn ServerOsApi>;
- fn send_to_client(&self, client_id: ClientId, msg: ServerToClientMsg);
+ fn send_to_client(
+ &self,
+ client_id: ClientId,
+ msg: ServerToClientMsg,
+ ) -> Result<(), &'static str>;
fn new_client(
&mut self,
client_id: ClientId,
@@ -373,9 +377,15 @@ impl ServerOsApi for ServerOsInputOutput {
let _ = kill(pid, Some(Signal::SIGKILL));
Ok(())
}
- fn send_to_client(&self, client_id: ClientId, msg: ServerToClientMsg) {
+ fn send_to_client(
+ &self,
+ client_id: ClientId,
+ msg: ServerToClientMsg,
+ ) -> Result<(), &'static str> {
if let Some(sender) = self.client_senders.lock().unwrap().get_mut(&client_id) {
- sender.send(msg);
+ sender.send(msg)
+ } else {
+ Ok(())
}
}
fn new_client(