mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-06 04:55:16 +02:00
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:
@@ -1181,15 +1181,9 @@ enum SubCommand {
|
|||||||
pub fn send_message(bytes: &[u8]) -> Result<()> {
|
pub fn send_message(bytes: &[u8]) -> Result<()> {
|
||||||
let socket = DATA_DIR.join("komorebi.sock");
|
let socket = DATA_DIR.join("komorebi.sock");
|
||||||
|
|
||||||
let mut connected = false;
|
let mut stream = UnixStream::connect(socket)?;
|
||||||
while !connected {
|
stream.write_all(bytes)?;
|
||||||
if let Ok(mut stream) = UnixStream::connect(&socket) {
|
Ok(stream.shutdown(Shutdown::Write)?)
|
||||||
connected = true;
|
|
||||||
stream.write_all(bytes)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_query(bytes: &[u8]) -> Result<String> {
|
pub fn send_query(bytes: &[u8]) -> Result<String> {
|
||||||
|
|||||||
Reference in New Issue
Block a user