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);
|
bool add_signal(int signal);
|
||||||
|
|
||||||
// blocks semaphore and returns either on unblock, eintr or spuriously
|
// 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_rsp(uintptr_t& rsp) { m_return_rsp = &rsp; }
|
||||||
void set_return_rip(uintptr_t& rip) { m_return_rip = &rip; }
|
void set_return_rip(uintptr_t& rip) { m_return_rip = &rip; }
|
||||||
|
|
|
@ -322,11 +322,11 @@ namespace Kernel
|
||||||
uint32_t depth = m_lock.lock_depth();
|
uint32_t depth = m_lock.lock_depth();
|
||||||
for (uint32_t i = 0; i < depth; i++)
|
for (uint32_t i = 0; i < depth; i++)
|
||||||
m_lock.unlock();
|
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++)
|
for (uint32_t i = 0; i < depth; i++)
|
||||||
m_lock.lock();
|
m_lock.lock();
|
||||||
if (eintr)
|
if (eintr.is_error())
|
||||||
return BAN::Error::from_errno(EINTR);
|
return eintr.release_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_output.bytes == 0)
|
if (m_output.bytes == 0)
|
||||||
|
|
|
@ -343,12 +343,14 @@ namespace Kernel
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Thread::block_or_eintr(Semaphore& semaphore)
|
BAN::ErrorOr<void> Thread::block_or_eintr(Semaphore& semaphore)
|
||||||
{
|
{
|
||||||
if (is_interrupted_by_signal())
|
if (is_interrupted_by_signal())
|
||||||
return true;
|
return BAN::Error::from_errno(EINTR);
|
||||||
semaphore.block();
|
semaphore.block();
|
||||||
return is_interrupted_by_signal();
|
if (is_interrupted_by_signal())
|
||||||
|
return BAN::Error::from_errno(EINTR);
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::validate_stack() const
|
void Thread::validate_stack() const
|
||||||
|
|
Loading…
Reference in New Issue