mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
Revert "kernel: hosted: don't send responses twice"
This causes problems, and fixes an issue that doesn't actually exist.
Revert it.
This reverts commit fc9f597092.
This commit is contained in:
parent
d9272ba21a
commit
b8d9d1e1b3
2 changed files with 24 additions and 36 deletions
|
|
@ -550,7 +550,6 @@ pub fn idle() -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the syscall within the Xous kernel
|
// Handle the syscall within the Xous kernel
|
||||||
crate::arch::process::clear_response_sent_already();
|
|
||||||
let response =
|
let response =
|
||||||
crate::syscall::handle(pid, thread_id, false, call).unwrap_or_else(Result::Error);
|
crate::syscall::handle(pid, thread_id, false, call).unwrap_or_else(Result::Error);
|
||||||
|
|
||||||
|
|
@ -575,18 +574,17 @@ pub fn idle() -> bool {
|
||||||
let s = unsafe { core::slice::from_raw_parts(mem.as_ptr(), mem.len()) };
|
let s = unsafe { core::slice::from_raw_parts(mem.as_ptr(), mem.len()) };
|
||||||
response_vec.extend_from_slice(s);
|
response_vec.extend_from_slice(s);
|
||||||
}
|
}
|
||||||
// Send a response only if we haven't already sent one
|
process.send(&response_vec).unwrap_or_else(|_e| {
|
||||||
if ! crate::arch::process::response_sent_already() {
|
// If we're unable to send data to the process, assume it's dead and terminate it.
|
||||||
process.send(&response_vec).unwrap_or_else(|_e| {
|
eprintln!(
|
||||||
// If we're unable to send data to the process, assume it's dead and terminate it.
|
"KERNEL({}): Unable to send response to process: {:?} -- terminating",
|
||||||
eprintln!(
|
pid, _e
|
||||||
"KERNEL({}): Unable to send response to process: {:?} -- terminating",
|
);
|
||||||
pid, _e
|
crate::syscall::handle(pid, thread_id, false, SysCall::TerminateProcess).ok();
|
||||||
);
|
});
|
||||||
crate::syscall::handle(pid, thread_id, false, SysCall::TerminateProcess).ok();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
crate::arch::process::set_current_pid(existing_pid);
|
crate::arch::process::set_current_pid(existing_pid);
|
||||||
|
// SystemServices::with_mut(|ss| {
|
||||||
|
// ss.switch_from(pid, 1, true)}).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_shutdown {
|
if is_shutdown {
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,6 @@ struct ProcessImpl {
|
||||||
/// Memory that may need to be returned to the caller for each thread
|
/// Memory that may need to be returned to the caller for each thread
|
||||||
memory_to_return: [Option<Vec<u8>>; MAX_THREAD + 1],
|
memory_to_return: [Option<Vec<u8>>; MAX_THREAD + 1],
|
||||||
|
|
||||||
/// We've already sent a response, so don't send another one
|
|
||||||
response_sent: bool,
|
|
||||||
|
|
||||||
/// This enables the kernel to keep track of threads in the
|
/// This enables the kernel to keep track of threads in the
|
||||||
/// target process, and know which threads are ready to
|
/// target process, and know which threads are ready to
|
||||||
/// receive messages.
|
/// receive messages.
|
||||||
|
|
@ -61,27 +58,9 @@ thread_local!(
|
||||||
current: unsafe { PID::new_unchecked(1) },
|
current: unsafe { PID::new_unchecked(1) },
|
||||||
total: 0,
|
total: 0,
|
||||||
table: Vec::new(),
|
table: Vec::new(),
|
||||||
});
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn response_sent_already() -> bool {
|
|
||||||
PROCESS_TABLE.with(|pt| {
|
|
||||||
let mut process_table = pt.borrow_mut();
|
|
||||||
let current_pid_idx = process_table.current.get() as usize - 1;
|
|
||||||
let process = &mut process_table.table[current_pid_idx].as_mut().unwrap();
|
|
||||||
process.response_sent
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn clear_response_sent_already() {
|
|
||||||
PROCESS_TABLE.with(|pt| {
|
|
||||||
let mut process_table = pt.borrow_mut();
|
|
||||||
let current_pid_idx = process_table.current.get() as usize - 1;
|
|
||||||
let process = &mut process_table.table[current_pid_idx].as_mut().unwrap();
|
|
||||||
process.response_sent = false;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn current_pid() -> PID {
|
pub fn current_pid() -> PID {
|
||||||
PROCESS_TABLE.with(|pt| pt.borrow().current)
|
PROCESS_TABLE.with(|pt| pt.borrow().current)
|
||||||
}
|
}
|
||||||
|
|
@ -320,10 +299,22 @@ impl Process {
|
||||||
if result.memory().is_some() {
|
if result.memory().is_some() {
|
||||||
panic!("Result has memory and we're also returning memory!");
|
panic!("Result has memory and we're also returning memory!");
|
||||||
}
|
}
|
||||||
|
// if let xous_kernel::Result::Message(_) = result {
|
||||||
|
// } else {
|
||||||
|
// panic!(
|
||||||
|
// "memory was waiting to be returned, but message was not a result message"
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
print!(" [adding {} additional bytes from memory being returned]", buf.len());
|
||||||
response.extend_from_slice(&buf);
|
response.extend_from_slice(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.response_sent = true;
|
// eprintln!(
|
||||||
|
// "KERNEL({}): Setting thread return value to {:?}",
|
||||||
|
// current_pid_idx + 1,
|
||||||
|
// response
|
||||||
|
// );
|
||||||
|
print!(" [setting thread return value to {} bytes]", response.len());
|
||||||
process
|
process
|
||||||
.conn
|
.conn
|
||||||
.as_mut()
|
.as_mut()
|
||||||
|
|
@ -356,7 +347,6 @@ impl Process {
|
||||||
conn: None,
|
conn: None,
|
||||||
key: init_data.key,
|
key: init_data.key,
|
||||||
memory_to_return: filled_array![None; 32 /* MAX_THREAD */],
|
memory_to_return: filled_array![None; 32 /* MAX_THREAD */],
|
||||||
response_sent: false,
|
|
||||||
current_thread: INITIAL_TID,
|
current_thread: INITIAL_TID,
|
||||||
threads: [Thread { allocated: false }; MAX_THREAD + 1],
|
threads: [Thread { allocated: false }; MAX_THREAD + 1],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue