diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 3f532741c..4e7c5df14 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -162,7 +162,7 @@ fn spawn_terminal(file_to_open: Option, orig_termios: termios::Termios) /// Sends messages on an [ipmpsc](ipmpsc) channel, along with an [`ErrorContext`]. struct IpcSenderWithContext { - sender: LocalSocketStream, + sender: io::BufWriter, _phantom: PhantomData, } @@ -170,7 +170,7 @@ impl IpcSenderWithContext { /// Returns a sender to the given [SharedRingBuffer](ipmpsc::SharedRingBuffer). fn new(sender: LocalSocketStream) -> Self { Self { - sender, + sender: io::BufWriter::new(sender), _phantom: PhantomData, } } @@ -188,7 +188,7 @@ impl IpcSenderWithContext { #[derive(Clone)] pub struct ServerOsInputOutput { orig_termios: Arc>, - recv_socket: Option>>, + recv_socket: Option>>>, sender_socket: Arc>>>, } @@ -282,13 +282,14 @@ impl ServerOsApi for ServerOsInputOutput { .unwrap() .lock() .unwrap() + .get_ref() .as_raw_fd(); let dup_fd = unistd::dup(sock_fd).unwrap(); let dup_sock = unsafe { LocalSocketStream::from_raw_fd(dup_fd) }; *self.sender_socket.lock().unwrap() = Some(IpcSenderWithContext::new(dup_sock)); } fn update_receiver(&mut self, stream: LocalSocketStream) { - self.recv_socket = Some(Arc::new(Mutex::new(stream))); + self.recv_socket = Some(Arc::new(Mutex::new(io::BufReader::new(stream)))); } } @@ -312,7 +313,7 @@ pub fn get_server_os_input() -> ServerOsInputOutput { pub struct ClientOsInputOutput { orig_termios: Arc>, server_sender: Arc>>>, - receiver: Arc>>, + receiver: Arc>>>, } /// The `ClientOsApi` trait represents an abstract interface to the features of an operating system that @@ -417,7 +418,7 @@ impl ClientOsApi for ClientOsInputOutput { let receiver = unsafe { LocalSocketStream::from_raw_fd(dup_fd) }; let sender = IpcSenderWithContext::new(socket); *self.server_sender.lock().unwrap() = Some(sender); - *self.receiver.lock().unwrap() = Some(receiver); + *self.receiver.lock().unwrap() = Some(io::BufReader::new(receiver)); } }