From b9332942a8fa59ceb40868b379f1752ee8d8f81f Mon Sep 17 00:00:00 2001 From: Louis Vialar Date: Wed, 17 Sep 2025 16:04:02 +0200 Subject: [PATCH] cleanup: poll_on no longer required in new_idle --- src/executor/mod.rs | 18 --------- src/scheduler/task.rs | 86 ++++++++++++++++++++----------------------- 2 files changed, 40 insertions(+), 64 deletions(-) diff --git a/src/executor/mod.rs b/src/executor/mod.rs index 298805a992..1451b662e1 100644 --- a/src/executor/mod.rs +++ b/src/executor/mod.rs @@ -125,24 +125,6 @@ pub fn init() { crate::executor::vsock::init(); } -/// Blocks the current thread on `f`, running the executor when idling. -pub(crate) fn poll_on(future: F) -> io::Result -where - F: Future>, -{ - let mut cx = Context::from_waker(Waker::noop()); - let mut future = pin!(future); - - loop { - // run background tasks - run(); - - if let Poll::Ready(t) = future.as_mut().poll(&mut cx) { - return t; - } - } -} - /// Blocks the current thread on `f`, running the executor when idling. pub(crate) fn block_on(future: F, timeout: Option) -> io::Result where diff --git a/src/scheduler/task.rs b/src/scheduler/task.rs index 78d523b757..58e24fef1e 100644 --- a/src/scheduler/task.rs +++ b/src/scheduler/task.rs @@ -19,8 +19,6 @@ use crate::arch::core_local::*; use crate::arch::scheduler::TaskStacks; #[cfg(not(feature = "common-os"))] use crate::arch::scheduler::TaskTLS; -use crate::errno::Errno; -use crate::executor::poll_on; use crate::fd::stdio::*; use crate::fd::{FileDescriptor, ObjectInterface, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO}; use crate::scheduler::CoreId; @@ -467,50 +465,46 @@ impl Task { )))) .unwrap(); let objmap = OBJECT_MAP.get().unwrap().clone(); - let _ = poll_on(async { - let mut guard = objmap.write(); - if env::is_uhyve() { - guard - .try_insert( - STDIN_FILENO, - Arc::new(async_lock::RwLock::new(UhyveStdin::new())), - ) - .map_err(|_| Errno::Io)?; - guard - .try_insert( - STDOUT_FILENO, - Arc::new(async_lock::RwLock::new(UhyveStdout::new())), - ) - .map_err(|_| Errno::Io)?; - guard - .try_insert( - STDERR_FILENO, - Arc::new(async_lock::RwLock::new(UhyveStderr::new())), - ) - .map_err(|_| Errno::Io)?; - } else { - guard - .try_insert( - STDIN_FILENO, - Arc::new(async_lock::RwLock::new(GenericStdin::new())), - ) - .map_err(|_| Errno::Io)?; - guard - .try_insert( - STDOUT_FILENO, - Arc::new(async_lock::RwLock::new(GenericStdout::new())), - ) - .map_err(|_| Errno::Io)?; - guard - .try_insert( - STDERR_FILENO, - Arc::new(async_lock::RwLock::new(GenericStderr::new())), - ) - .map_err(|_| Errno::Io)?; - } - - Ok(()) - }); + let mut guard = objmap.write(); + if env::is_uhyve() { + guard + .try_insert( + STDIN_FILENO, + Arc::new(async_lock::RwLock::new(UhyveStdin::new())), + ) + .expect("cannot insert stdin"); + guard + .try_insert( + STDOUT_FILENO, + Arc::new(async_lock::RwLock::new(UhyveStdout::new())), + ) + .expect("cannot insert stdout"); + guard + .try_insert( + STDERR_FILENO, + Arc::new(async_lock::RwLock::new(UhyveStderr::new())), + ) + .expect("cannot insert stderr"); + } else { + guard + .try_insert( + STDIN_FILENO, + Arc::new(async_lock::RwLock::new(GenericStdin::new())), + ) + .expect("cannot insert stdin"); + guard + .try_insert( + STDOUT_FILENO, + Arc::new(async_lock::RwLock::new(GenericStdout::new())), + ) + .expect("cannot insert stdout"); + guard + .try_insert( + STDERR_FILENO, + Arc::new(async_lock::RwLock::new(GenericStderr::new())), + ) + .expect("cannot insert stderr"); + } } Task {