diff options
author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-03-22 09:05:08 +0530 |
---|---|---|
committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-04-14 01:41:32 +0530 |
commit | 341ab2aced1b2218c392d3a92bc7ae1d1ab53b81 (patch) | |
tree | b009d65ff113aa6b9e6667ab29b9c957f80c199a | |
parent | d7daa38c42b58a52002e9ef661f96dda8a562fbc (diff) |
documentation and nit fix
-rw-r--r-- | src/common/mod.rs | 4 | ||||
-rw-r--r-- | src/common/os_input_output.rs | 4 | ||||
-rw-r--r-- | src/server/mod.rs | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/common/mod.rs b/src/common/mod.rs index abe06c176..699ccdbcf 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -164,7 +164,7 @@ impl IpcSenderWithContext { } pub fn send<T: Serialize>(&mut self, msg: T) -> ipmpsc::Result<()> { - self.sender.send(&(self.err_ctx, msg)) + self.sender.send(&(msg, self.err_ctx)) } } @@ -559,7 +559,7 @@ pub fn start( .spawn({ let recv_client_instructions = IpcReceiver::new(client_buffer); move || loop { - let (err_ctx, instruction): (ErrorContext, ClientInstruction) = + let (instruction, err_ctx): (ClientInstruction, ErrorContext) = recv_client_instructions.recv().unwrap(); send_app_instructions.update(err_ctx); match instruction { diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 90bd0e491..b97834b52 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -180,7 +180,10 @@ pub trait ServerOsApi: Send + Sync { fn kill(&mut self, pid: RawFd) -> Result<(), nix::Error>; /// Returns a [`Box`] pointer to this [`OsApi`] struct. fn box_clone(&self) -> Box<dyn ServerOsApi>; + /// Returns the receiver of ServerInstructions. + // Should be called by server once only. fn get_server_receiver(&self) -> IpcReceiver; + /// Returns a sender to the Server. fn get_server_sender(&self) -> IpcSenderWithContext; } @@ -264,6 +267,7 @@ pub trait ClientOsApi: Send + Sync { fn read_from_stdin(&self) -> Vec<u8>; /// Returns a [`Box`] pointer to this [`OsApi`] struct. fn box_clone(&self) -> Box<dyn ClientOsApi>; + /// Returns a sender to the Server. fn get_server_sender(&self) -> IpcResult<IpcSenderWithContext>; } diff --git a/src/server/mod.rs b/src/server/mod.rs index 3c6918eaf..b902ea27b 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -147,7 +147,7 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, opts: CliArgs) -> thread::Jo // For now, We make sure that the first message is `NewClient` so there are no out of bound panics. let mut send_client_instructions: Vec<IpcSenderWithContext> = Vec::with_capacity(1); move || loop { - let (mut err_ctx, instruction): (ErrorContext, ServerInstruction) = + let (instruction, mut err_ctx): (ServerInstruction, ErrorContext) = recv_server_instructions.recv().unwrap(); err_ctx.add_call(ContextType::IPCServer(ServerContext::from(&instruction))); send_pty_instructions.update(err_ctx); |