diff --git a/cli/src/tunnels/code_server.rs b/cli/src/tunnels/code_server.rs index 74a8b00efbe59..cf0beeec2bcab 100644 --- a/cli/src/tunnels/code_server.rs +++ b/cli/src/tunnels/code_server.rs @@ -240,15 +240,6 @@ pub enum AnyCodeServer { Port(PortCodeServer), } -// impl AnyCodeServer { -// pub fn origin(&mut self) -> &mut CodeServerOrigin { -// match self { -// AnyCodeServer::Socket(p) => &mut p.origin, -// AnyCodeServer::Port(p) => &mut p.origin, -// } -// } -// } - pub enum CodeServerOrigin { /// A new code server, that opens the barrier when it exits. New(Box), diff --git a/cli/src/tunnels/control_server.rs b/cli/src/tunnels/control_server.rs index c7f033d1b0158..08d65207b7e2b 100644 --- a/cli/src/tunnels/control_server.rs +++ b/cli/src/tunnels/control_server.rs @@ -94,9 +94,7 @@ impl HandlerContext { async fn dispose(self) { let bridges: ServerBridgeList = { let mut lock = self.server_bridges.lock().await; - let bridges = lock.take(); - *lock = None; - bridges + lock.take() }; if let Some(b) = bridges { diff --git a/cli/src/util/machine.rs b/cli/src/util/machine.rs index cac5407893a86..c3e0e2bfb98d9 100644 --- a/cli/src/util/machine.rs +++ b/cli/src/util/machine.rs @@ -7,35 +7,30 @@ use std::path::Path; use sysinfo::{Pid, PidExt, ProcessExt, System, SystemExt}; pub fn process_at_path_exists(pid: u32, name: &Path) -> bool { - // TODO https://docs.rs/sysinfo/latest/sysinfo/index.html#usage - let mut sys = System::new_all(); - sys.refresh_processes(); + let mut sys = System::new(); + let pid = Pid::from_u32(pid); + if !sys.refresh_process(pid) { + return false; + } let name_str = format!("{}", name.display()); - match sys.process(Pid::from_u32(pid)) { - Some(process) => { - for cmd in process.cmd() { - if cmd.contains(&name_str) { - return true; - } + if let Some(process) = sys.process(pid) { + for cmd in process.cmd() { + if cmd.contains(&name_str) { + return true; } } - None => { - return false; - } } false } pub fn process_exists(pid: u32) -> bool { - let mut sys = System::new_all(); - sys.refresh_processes(); - sys.process(Pid::from_u32(pid)).is_some() + let mut sys = System::new(); + sys.refresh_process(Pid::from_u32(pid)) } pub fn find_running_process(name: &Path) -> Option { - // TODO https://docs.rs/sysinfo/latest/sysinfo/index.html#usage - let mut sys = System::new_all(); + let mut sys = System::new(); sys.refresh_processes(); let name_str = format!("{}", name.display());