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
c8f6502b02.

@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.
This commit is contained in:
LGUG2Z
2024-02-25 08:17:18 -08:00
parent 8642ac0946
commit c19f64144a

View File

@@ -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<String> {