diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-11 11:47:08 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-15 22:14:34 +0530 |
| commit | 0d792e26f23ad8e1fc2dd44555cae79427361c15 (patch) | |
| tree | 7f2d28387b18dc089c961f7bffc60585f878df39 /src/common | |
| parent | docs(changelog): Remove unused import (diff) | |
| download | sl0ppij-0d792e26f23ad8e1fc2dd44555cae79427361c15.tar.gz sl0ppij-0d792e26f23ad8e1fc2dd44555cae79427361c15.tar.xz sl0ppij-0d792e26f23ad8e1fc2dd44555cae79427361c15.zip | |
Switch to multiprocess model: Not looking good
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/os_input_output.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 6f891e0d..2a9a14e0 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -1,8 +1,5 @@ use crate::client::ClientInstruction; -use crate::common::{ - ipc::{IpcReceiverWithContext, IpcSenderWithContext}, - utils::consts::ZELLIJ_IPC_PIPE, -}; +use crate::common::ipc::{IpcReceiverWithContext, IpcSenderWithContext}; use crate::errors::ErrorContext; use crate::panes::PositionAndSize; use crate::server::ServerInstruction; @@ -319,7 +316,7 @@ pub trait ClientOsApi: Send + Sync { fn recv_from_server(&self) -> (ClientInstruction, ErrorContext); fn receive_sigwinch(&self, cb: Box<dyn Fn()>); /// Establish a connection with the server socket. - fn connect_to_server(&self); + fn connect_to_server(&self, path: &Path); } impl ClientOsApi for ClientOsInputOutput { @@ -379,14 +376,19 @@ impl ClientOsApi for ClientOsInputOutput { } } } - fn connect_to_server(&self) { - let socket = match LocalSocketStream::connect(&**ZELLIJ_IPC_PIPE) { - Ok(sock) => sock, - Err(_) => { - std::thread::sleep(std::time::Duration::from_millis(20)); - LocalSocketStream::connect(&**ZELLIJ_IPC_PIPE).unwrap() + fn connect_to_server(&self, path: &Path) { + let socket; + loop { + match LocalSocketStream::connect(path) { + Ok(sock) => { + socket = sock; + break; + } + Err(_) => { + std::thread::sleep(std::time::Duration::from_millis(50)); + } } - }; + } let sender = IpcSenderWithContext::new(socket); let receiver = sender.get_receiver(); *self.send_instructions_to_server.lock().unwrap() = Some(sender); |
