hosted: set tcp_nodelay

This might have a performance impact, but it's unclear.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-03-13 18:05:11 +08:00
parent f960c1cb4a
commit 9c8b562711
2 changed files with 7 additions and 4 deletions

View file

@ -312,6 +312,7 @@ fn listen_thread(
// Read the challenge access key from the client // Read the challenge access key from the client
let mut access_key = [0u8; 16]; let mut access_key = [0u8; 16];
conn.read_exact(&mut access_key).unwrap(); conn.read_exact(&mut access_key).unwrap();
conn.set_nodelay(true).unwrap();
// Spawn a new process. This process will start out in the "Allocated" state. // Spawn a new process. This process will start out in the "Allocated" state.
chn.send(ThreadMessage::NewConnection( chn.send(ThreadMessage::NewConnection(

View file

@ -397,6 +397,7 @@ fn xous_connect_impl(
Ok(mut conn) => { Ok(mut conn) => {
conn.write_all(&key.0).unwrap(); // Send key to authenticate us as PID 1 conn.write_all(&key.0).unwrap(); // Send key to authenticate us as PID 1
conn.flush().unwrap(); conn.flush().unwrap();
conn.set_nodelay(true).unwrap();
let mut pid = [0u8]; let mut pid = [0u8];
conn.read_exact(&mut pid).unwrap(); conn.read_exact(&mut pid).unwrap();
PROCESS_ID.with(|process_id| *process_id.borrow_mut() = PID::new(pid[0]).unwrap()); PROCESS_ID.with(|process_id| *process_id.borrow_mut() = PID::new(pid[0]).unwrap());
@ -456,7 +457,7 @@ pub fn _xous_syscall(
a6, a6,
a7, a7,
&call, &call,
&mut xsc_asmut.send.lock().unwrap(), xsc_asmut
); );
_xous_syscall_result(ret, *tid.borrow(), xsc_asmut); _xous_syscall_result(ret, *tid.borrow(), xsc_asmut);
if *ret != Result::WouldBlock { if *ret != Result::WouldBlock {
@ -656,7 +657,7 @@ fn _xous_syscall_to(
a6: usize, a6: usize,
a7: usize, a7: usize,
call: &crate::SysCall, call: &crate::SysCall,
xsc: &mut TcpStream, xsc: &mut ServerConnection,
) { ) {
// println!( // println!(
// "Making Syscall: {:?}", // "Making Syscall: {:?}",
@ -677,9 +678,10 @@ fn _xous_syscall_to(
pkt.extend_from_slice(data); pkt.extend_from_slice(data);
} }
if let Err(e) = xsc.write_all(&pkt) { let mut stream = xsc.send.lock().unwrap();
if let Err(e) = stream.write_all(&pkt) {
eprintln!("Server shut down: {}", e); eprintln!("Server shut down: {}", e);
std::process::exit(0); std::process::exit(0);
} }
xsc.flush().unwrap(); // stream.flush().unwrap();
} }