Revert "Make pause_timeout return EINTR"

This reverts commit 6421fd0b36.
This commit is contained in:
Ruihan Li
2024-11-09 11:55:14 +08:00
parent 12aa9fc857
commit 7a017faa44

View File

@ -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::<Arc<Thread>>()
let current_thread = self.task().data().downcast_ref::<Arc<Thread>>();
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::<Arc<Thread>>()
.and_then(|thread| thread.as_posix_thread());
let current_thread = self.task().data().downcast_ref::<Arc<Thread>>();
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(())
}
}