forked from Bananymous/banan-os
Kernel: Update block_or_eintr API to return ErrorOr<>
This commit is contained in:
parent
40f55be587
commit
41ae05dd6e
|
@ -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; }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue