mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
hosted: transmit PID to clients
Prior to this patch, all clients assumed they were PID 1. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
7271e54f2f
commit
e00b958308
2 changed files with 5 additions and 1 deletions
|
|
@ -91,7 +91,7 @@ pub fn set_current_pid(pid: PID) {
|
|||
}
|
||||
|
||||
pub fn register_connection_for_key(
|
||||
conn: TcpStream,
|
||||
mut conn: TcpStream,
|
||||
key: ProcessKey,
|
||||
) -> Result<PID, xous_kernel::Error> {
|
||||
PROCESS_TABLE.with(|pt| {
|
||||
|
|
@ -99,6 +99,7 @@ pub fn register_connection_for_key(
|
|||
for (pid_minus_1, process) in process_table.table.iter_mut().enumerate() {
|
||||
if let Some(process) = process.as_mut() {
|
||||
if process.key == key && process.conn.is_none() {
|
||||
conn.write_all(&[pid_minus_1 as u8 + 1]).unwrap();
|
||||
process.conn = Some(conn);
|
||||
return Ok(PID::new(pid_minus_1 as u8 + 1).unwrap());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -397,6 +397,9 @@ fn xous_connect_impl(
|
|||
Ok(mut conn) => {
|
||||
conn.write_all(&key.0).unwrap(); // Send key to authenticate us as PID 1
|
||||
conn.flush().unwrap();
|
||||
let mut pid = [0u8];
|
||||
conn.read_exact(&mut pid).unwrap();
|
||||
PROCESS_ID.with(|process_id| *process_id.borrow_mut() = PID::new(pid[0]).unwrap());
|
||||
Ok(ServerConnection {
|
||||
send: Arc::new(Mutex::new(conn.try_clone().unwrap())),
|
||||
recv: Arc::new(Mutex::new(conn)),
|
||||
|
|
|
|||
Loading…
Reference in a new issue