From c19f64144a391696a12f0d5470f3a837ef05a416 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 25 Feb 2024 08:17:18 -0800 Subject: [PATCH] fix(cli): remove socket connection retry loop This commit remove the socket connection retry loop in send_message which is no longer required after @raggi's changes in c8f6502b0241c54d17854e06a58e68fdc634763a. @azinsharaf noticed that when trying to run komorebic commands while komorebi was not accepting connections, multiple hanging komorebic instances could be spawned, particularly if commands were retried. @eythaann proposed an additive fix for this in PR684 but ultimately as the previous race condition with the query/response commands has been handed by @raggi we can remove the socket connection retry loop completely. --- komorebic/src/main.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index f3b09623..0e8586de 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1181,15 +1181,9 @@ enum SubCommand { pub fn send_message(bytes: &[u8]) -> Result<()> { let socket = DATA_DIR.join("komorebi.sock"); - let mut connected = false; - while !connected { - if let Ok(mut stream) = UnixStream::connect(&socket) { - connected = true; - stream.write_all(bytes)?; - } - } - - Ok(()) + let mut stream = UnixStream::connect(socket)?; + stream.write_all(bytes)?; + Ok(stream.shutdown(Shutdown::Write)?) } pub fn send_query(bytes: &[u8]) -> Result {