feat(init): watchdog: pinger thread PINGs servers (framework answers, no server code), main kills after 5s unanswered -> crash path; not pinged: terminal, pm (handlers wait for user); give-up drains queued ping; spawntest hang check

This commit is contained in:
2026-10-28 01:51:39 +01:00
parent 28f1ace00a
commit 3d69c10079
9 changed files with 236 additions and 18 deletions

View File

@@ -200,6 +200,22 @@ fn restarted_after_crashes() -> Result<(), &'static str> {
Ok(())
}
/// A server stuck in a handler is noticed by the watchdog, killed (which
/// releases its caller) and restarted.
fn restarted_after_hanging() -> Result<(), &'static str> {
let asked = syscall::get_time().raw();
// Comes back, with an error, once the hung server is killed.
let _ = syscall::request(FLAKY, [flaky::op::HANG, 0, 0, 0]);
let hung_ms = (syscall::get_time().raw() - asked) / 10_000;
if hung_ms < 4_500 {
return Err("the hung server was stopped before the watchdog's deadline");
}
if flaky()? != 1 {
return Err("the hung server was not restarted");
}
Ok(())
}
fn check() -> Result<(), &'static str> {
let mut fs = Storage::attach(STORAGE, STORAGE_BUF_VA).map_err(|_| "cannot attach to storage")?;
write_a_file(&mut fs)?;
@@ -232,6 +248,9 @@ fn check() -> Result<(), &'static str> {
restarted_after_crashes()?;
libkos::println!("spawntest: a crashed server is restarted, a crash loop backs off: ok");
restarted_after_hanging()?;
libkos::println!("spawntest: a hung server is noticed, stopped and restarted: ok");
Ok(())
}