mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-22 16:11:38 +03:00
kernel: only reboot persisted processes if their OnExit behavior is not None
This commit is contained in:
parent
fccff76023
commit
6082ee6533
@ -716,18 +716,19 @@ pub async fn kernel(
|
|||||||
let mut is_debug: bool = false;
|
let mut is_debug: bool = false;
|
||||||
let mut reboot_processes: Vec<(t::ProcessId, StartProcessMetadata, Vec<u8>)> = vec![];
|
let mut reboot_processes: Vec<(t::ProcessId, StartProcessMetadata, Vec<u8>)> = vec![];
|
||||||
|
|
||||||
|
// filter out OnExit::None processes from process_map
|
||||||
|
process_map.retain(|_, persisted| !persisted.on_exit.is_none());
|
||||||
|
|
||||||
for (process_id, persisted) in &process_map {
|
for (process_id, persisted) in &process_map {
|
||||||
// runtime extensions will have a bytes_handle of "", because they have no
|
// runtime extensions will have a bytes_handle of "", because they have no
|
||||||
// WASM code saved in filesystem.
|
// WASM code saved in filesystem.
|
||||||
if persisted.on_exit.is_restart() && !persisted.wasm_bytes_handle.is_empty() {
|
if persisted.wasm_bytes_handle.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// read wasm bytes directly from vfs
|
// read wasm bytes directly from vfs
|
||||||
// start process.
|
// start process.
|
||||||
let wasm_bytes = match tokio::fs::read(format!(
|
let wasm_bytes =
|
||||||
"{}/{}",
|
match tokio::fs::read(format!("{}/{}", vfs_path, persisted.wasm_bytes_handle)).await {
|
||||||
vfs_path, persisted.wasm_bytes_handle
|
|
||||||
))
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(bytes) => bytes,
|
Ok(bytes) => bytes,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _ = send_to_terminal
|
let _ = send_to_terminal
|
||||||
@ -755,7 +756,6 @@ pub async fn kernel(
|
|||||||
},
|
},
|
||||||
wasm_bytes,
|
wasm_bytes,
|
||||||
));
|
));
|
||||||
}
|
|
||||||
if let t::OnExit::Requests(requests) = &persisted.on_exit {
|
if let t::OnExit::Requests(requests) = &persisted.on_exit {
|
||||||
// if a persisted process had on-death-requests, we should perform them now
|
// if a persisted process had on-death-requests, we should perform them now
|
||||||
// even in death, a process can only message processes it has capabilities for
|
// even in death, a process can only message processes it has capabilities for
|
||||||
|
@ -483,6 +483,14 @@ impl OnExit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_none(&self) -> bool {
|
||||||
|
match self {
|
||||||
|
OnExit::None => true,
|
||||||
|
OnExit::Restart => false,
|
||||||
|
OnExit::Requests(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn en_wit(&self) -> wit::OnExit {
|
pub fn en_wit(&self) -> wit::OnExit {
|
||||||
match self {
|
match self {
|
||||||
OnExit::None => wit::OnExit::None,
|
OnExit::None => wit::OnExit::None,
|
||||||
|
Loading…
Reference in New Issue
Block a user