diff --git a/src/common/mod.rs b/src/common/mod.rs index ef9fc47f..bb59f1d2 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -10,7 +10,7 @@ pub mod utils; pub mod wasm_vm; use std::io::Write; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::sync::mpsc; use std::thread; use std::{collections::HashMap, fs}; @@ -183,7 +183,7 @@ pub fn start( let mut send_app_instructions = SenderWithContext::new(err_ctx, SenderType::SyncSender(send_app_instructions)); - os_input.notify_server(); + os_input.connect_to_server(); #[cfg(not(test))] std::panic::set_hook({ diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 62006162..396a1955 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -342,7 +342,7 @@ pub trait ClientOsApi: Send + Sync { // This should be called from the client-side router thread only. fn client_recv(&self) -> (ClientInstruction, ErrorContext); /// Setup the client IpcChannel and notify server of new client - fn notify_server(&mut self); + fn connect_to_server(&mut self); } impl ClientOsApi for ClientOsInputOutput { @@ -378,7 +378,7 @@ impl ClientOsApi for ClientOsInputOutput { fn update_senders(&mut self, new_ctx: ErrorContext) { self.server_sender.update(new_ctx); } - fn notify_server(&mut self) { + fn connect_to_server(&mut self) { let (client_buffer_path, client_buffer) = SharedRingBuffer::create_temp(IPC_BUFFER_SIZE).unwrap(); self.client_receiver = Some(Arc::new(Mutex::new(IpcReceiver::new( diff --git a/src/main.rs b/src/main.rs index eef590a4..e2d567c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,6 +75,7 @@ pub fn main() { } else if let Some(file_to_open) = opts.open_file { get_client_os_input().send_to_server(ServerInstruction::OpenFile(file_to_open)); } else { + // Mind the order: server_os_input should be created before client_os_input let server_os_input = get_server_os_input(); let os_input = get_client_os_input(); atomic_create_dir(ZELLIJ_TMP_DIR).unwrap(); diff --git a/src/tests/fakes.rs b/src/tests/fakes.rs index 32dde38f..edfd1247 100644 --- a/src/tests/fakes.rs +++ b/src/tests/fakes.rs @@ -189,7 +189,7 @@ impl ClientOsApi for FakeInputOutput { self.server_sender.update(new_ctx); self.client_sender.update(new_ctx); } - fn notify_server(&mut self) { + fn connect_to_server(&mut self) { ClientOsApi::send_to_server(self, ServerInstruction::NewClient("zellij".into())); } fn client_recv(&self) -> (ClientInstruction, ErrorContext) {