From 7a017faa44572b36a13527c044f9a674f9897d6c Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Sat, 9 Nov 2024 11:55:14 +0800 Subject: [PATCH] Revert "Make `pause_timeout` return `EINTR`" This reverts commit 6421fd0b36aafb3fcd9a8f12d5bc6e89f3f86546. --- kernel/src/process/signal/pause.rs | 36 +++++++++++------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/kernel/src/process/signal/pause.rs b/kernel/src/process/signal/pause.rs index d800fa51a..7184cbf89 100644 --- a/kernel/src/process/signal/pause.rs +++ b/kernel/src/process/signal/pause.rs @@ -86,9 +86,10 @@ pub trait Pause: WaitTimeout { /// /// # Errors /// - /// This method will return an error with - /// - [`EINTR`] if a signal is received; - /// - [`ETIME`] if the timeout is reached. + /// This method will return an error with [`ETIME`] if the timeout is reached. + /// + /// Unlike other methods in the trait, this method will _not_ return an error with [`EINTR`] if + /// a signal is received (FIXME). /// /// [`ETIME`]: crate::error::Errno::ETIME /// [`EINTR`]: crate::error::Errno::EINTR @@ -107,10 +108,10 @@ impl Pause for Waiter { // No fast paths for `Waiter`. If the caller wants a fast path, it should do so _before_ // the waiter is created. - let Some(posix_thread) = self - .task() - .data() - .downcast_ref::>() + let current_thread = self.task().data().downcast_ref::>(); + + let Some(posix_thread) = current_thread + .as_ref() .and_then(|thread| thread.as_posix_thread()) else { return self.wait_until_or_timeout_cancelled(cond, || Ok(()), timeout); @@ -141,13 +142,12 @@ impl Pause for Waiter { }) }); - let posix_thread_opt = self - .task() - .data() - .downcast_ref::>() - .and_then(|thread| thread.as_posix_thread()); + let current_thread = self.task().data().downcast_ref::>(); - if let Some(posix_thread) = posix_thread_opt { + if let Some(posix_thread) = current_thread + .as_ref() + .and_then(|thread| thread.as_posix_thread()) + { posix_thread.set_signalled_waker(self.waker()); self.wait(); posix_thread.clear_signalled_waker(); @@ -163,16 +163,6 @@ impl Pause for Waiter { timer.cancel(); } - if posix_thread_opt - .as_ref() - .is_some_and(|posix_thread| posix_thread.has_pending()) - { - return_errno_with_message!( - Errno::EINTR, - "the current thread is interrupted by a signal" - ); - } - Ok(()) } }