From ecdfd589fa711220107e1647a7d2128d82dceba7 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Wed, 21 Oct 2020 23:38:44 +0200 Subject: [PATCH] add read-timeout to client --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 758c7f4..50c6c8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -127,6 +127,13 @@ impl OptAction { } } } + + fn is_server_command(&self) -> bool { + match self { + OptAction::OpenWindow { .. } => true, + _ => false, + } + } } fn try_main() -> Result<()> { @@ -137,6 +144,7 @@ fn try_main() -> Result<()> { stream.write_all(&bincode::serialize(&opts)?)?; let mut buf = String::new(); + stream.set_read_timeout(Some(std::time::Duration::from_millis(100)))?; stream.read_to_string(&mut buf)?; println!("{}", buf); } else { @@ -154,7 +162,8 @@ fn try_main() -> Result<()> { } fn initialize_server(opts: Opt) -> Result<()> { - if opts.action == OptAction::KillServer { + if opts.action == OptAction::KillServer || !opts.action.is_server_command() { + println!("No eww server running"); return Ok(()); }