Kernel: Update block_or_eintr API to return ErrorOr<>

This commit is contained in:
Bananymous 2024-01-05 12:13:11 +02:00
parent 40f55be587
commit 41ae05dd6e
3 changed files with 9 additions and 7 deletions

View File

@ -48,7 +48,7 @@ namespace Kernel
bool add_signal(int signal);
// blocks semaphore and returns either on unblock, eintr or spuriously
[[nodiscard]] bool block_or_eintr(Semaphore&);
BAN::ErrorOr<void> block_or_eintr(Semaphore&);
void set_return_rsp(uintptr_t& rsp) { m_return_rsp = &rsp; }
void set_return_rip(uintptr_t& rip) { m_return_rip = &rip; }

View File

@ -322,11 +322,11 @@ namespace Kernel
uint32_t depth = m_lock.lock_depth();
for (uint32_t i = 0; i < depth; i++)
m_lock.unlock();
bool eintr = Thread::current().block_or_eintr(m_output.semaphore);
auto eintr = Thread::current().block_or_eintr(m_output.semaphore);
for (uint32_t i = 0; i < depth; i++)
m_lock.lock();
if (eintr)
return BAN::Error::from_errno(EINTR);
if (eintr.is_error())
return eintr.release_error();
}
if (m_output.bytes == 0)

View File

@ -343,12 +343,14 @@ namespace Kernel
return false;
}
bool Thread::block_or_eintr(Semaphore& semaphore)
BAN::ErrorOr<void> Thread::block_or_eintr(Semaphore& semaphore)
{
if (is_interrupted_by_signal())
return true;
return BAN::Error::from_errno(EINTR);
semaphore.block();
return is_interrupted_by_signal();
if (is_interrupted_by_signal())
return BAN::Error::from_errno(EINTR);
return {};
}
void Thread::validate_stack() const