use bincode::deserialize_from() to prevent data loss.
This commit is contained in:
parent
da9b6fd607
commit
93956bdcca
1 changed files with 2 additions and 22 deletions
|
|
@ -22,8 +22,6 @@ use crate::errors::{get_current_ctx, ErrorContext};
|
||||||
use crate::panes::PositionAndSize;
|
use crate::panes::PositionAndSize;
|
||||||
use crate::server::ServerInstruction;
|
use crate::server::ServerInstruction;
|
||||||
|
|
||||||
const IPC_BUFFER_SIZE: usize = 262144;
|
|
||||||
|
|
||||||
fn into_raw_mode(pid: RawFd) {
|
fn into_raw_mode(pid: RawFd) {
|
||||||
let mut tio = termios::tcgetattr(pid).expect("could not get terminal attribute");
|
let mut tio = termios::tcgetattr(pid).expect("could not get terminal attribute");
|
||||||
termios::cfmakeraw(&mut tio);
|
termios::cfmakeraw(&mut tio);
|
||||||
|
|
@ -254,16 +252,7 @@ impl ServerOsApi for ServerOsInputOutput {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn server_recv(&self) -> (ServerInstruction, ErrorContext) {
|
fn server_recv(&self) -> (ServerInstruction, ErrorContext) {
|
||||||
let mut buf = [0; IPC_BUFFER_SIZE];
|
bincode::deserialize_from(&mut *self.recv_socket.as_ref().unwrap().lock().unwrap()).unwrap()
|
||||||
let bytes = self
|
|
||||||
.recv_socket
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.read(&mut buf)
|
|
||||||
.unwrap();
|
|
||||||
bincode::deserialize(&buf[..bytes]).unwrap()
|
|
||||||
}
|
}
|
||||||
fn send_to_client(&self, msg: ClientInstruction) {
|
fn send_to_client(&self, msg: ClientInstruction) {
|
||||||
self.sender_socket
|
self.sender_socket
|
||||||
|
|
@ -380,16 +369,7 @@ impl ClientOsApi for ClientOsInputOutput {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
fn client_recv(&self) -> (ClientInstruction, ErrorContext) {
|
fn client_recv(&self) -> (ClientInstruction, ErrorContext) {
|
||||||
let mut buf = [0; IPC_BUFFER_SIZE];
|
bincode::deserialize_from(&mut self.receiver.lock().unwrap().as_mut().unwrap()).unwrap()
|
||||||
let bytes = self
|
|
||||||
.receiver
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.read(&mut buf)
|
|
||||||
.unwrap();
|
|
||||||
bincode::deserialize(&buf[..bytes]).unwrap()
|
|
||||||
}
|
}
|
||||||
fn receive_sigwinch(&self, cb: Box<dyn Fn()>) {
|
fn receive_sigwinch(&self, cb: Box<dyn Fn()>) {
|
||||||
let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).unwrap();
|
let mut signals = Signals::new(&[SIGWINCH, SIGTERM, SIGINT, SIGQUIT]).unwrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue