From 152f8be7b1d382cbc1ea12cde23a44bea5c1a395 Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Mon, 28 Oct 2024 11:14:01 +0800 Subject: [PATCH] No need to write address twice Optimize code Signed-off-by: jokemanfire --- crates/shim/src/asynchronous/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/shim/src/asynchronous/mod.rs b/crates/shim/src/asynchronous/mod.rs index 4a145310..508970ff 100644 --- a/crates/shim/src/asynchronous/mod.rs +++ b/crates/shim/src/asynchronous/mod.rs @@ -54,7 +54,7 @@ use crate::{ asynchronous::{monitor::monitor_notify_by_pid, publisher::RemotePublisher}, error::{Error, Result}, logger, parse_sockaddr, reap, socket_address, - util::{asyncify, read_file_to_str, write_str_to_file}, + util::{asyncify, read_file_to_str}, Config, Flags, StartOpts, SOCKET_FD, TTRPC_ADDRESS, }; @@ -260,8 +260,7 @@ pub async fn spawn(opts: StartOpts, grouping: &str, vars: Vec<(&str, &str)>) -> return Err(e); }; } - if let Ok(()) = wait_socket_working(&address, 5, 200).await { - write_str_to_file("address", &address).await?; + if wait_socket_working(&address, 5, 200).await.is_ok() { return Ok(address); } remove_socket(&address).await?;