From b485bf16a7994aa8dd7bdaa567112745b36a3b5f Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 2 Sep 2024 17:08:00 +0800 Subject: [PATCH] extremely wip --- src/runtime/src/comms.rs | 10 +++++++--- src/runtime/src/mgmt.rs | 5 +++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/runtime/src/comms.rs b/src/runtime/src/comms.rs index cf54bab..0da9d9f 100644 --- a/src/runtime/src/comms.rs +++ b/src/runtime/src/comms.rs @@ -861,7 +861,9 @@ pub fn main(timer: GlobalTimer, cfg: Config) { // keep yielding }) => (), _ = terminate.async_wait().fuse() => (), - _ = restart_idle.async_wait().fuse() => () + _ = async { + restart_idle.async_wait().fuse(), + } } connection.signal(); }); @@ -926,8 +928,10 @@ pub fn main(timer: GlobalTimer, cfg: Config) { load_and_run_idle_kernel(&buffer, &control, &up_destinations, &aux_mutex, &routing_table, timer).await; } }).fuse() => (), - _ = terminate.async_wait().fuse() => (), - _ = restart_idle.async_wait().fuse() => () + _ = (async { + restart_idle.0.async_wait().await; + restart_idle.1.signal(); + }).fuse() => (), } drop(_lock); } diff --git a/src/runtime/src/mgmt.rs b/src/runtime/src/mgmt.rs index ea79327..1eebd1e 100644 --- a/src/runtime/src/mgmt.rs +++ b/src/runtime/src/mgmt.rs @@ -201,10 +201,11 @@ async fn handle_connection(stream: &mut TcpStream, pull_id: Rc>, cf let value = cfg.write(&key, buffer); if value.is_ok() { debug!("write success"); - write_i8(stream, Reply::Success as i8).await?; if key == "idle_kernel" { - restart_idle.signal(); + restart_idle.1.async_wait().await?; + restart_idle.0.signal(); } + write_i8(stream, Reply::Success as i8).await?; } else { // this is an error because we do not expect write to fail error!("failed to write: {:?}", value);