mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:37:36 +00:00
Thread: Return a result from block() indicating why the block terminated
And use this to return EINTR in various places; some of which we were not handling properly before. This might expose a few bugs in userspace, but should be more compatible with other POSIX systems, and is certainly a little cleaner.
This commit is contained in:
parent
56217c7432
commit
833d444cd8
9 changed files with 73 additions and 38 deletions
|
@ -212,10 +212,13 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t
|
|||
}
|
||||
|
||||
load_receive_deadline();
|
||||
current->block<Thread::ReceiveBlocker>(description);
|
||||
auto res = current->block<Thread::ReceiveBlocker>(description);
|
||||
|
||||
LOCKER(lock());
|
||||
if (!m_can_read) {
|
||||
if (res == Thread::BlockResult::InterruptedBySignal)
|
||||
return -EINTR;
|
||||
|
||||
// Unblocked due to timeout.
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ void NetworkTask_main()
|
|||
for (;;) {
|
||||
auto packet = dequeue_packet();
|
||||
if (packet.is_null()) {
|
||||
current->block_until("Networking", [] {
|
||||
(void)current->block_until("Networking", [] {
|
||||
if (LoopbackAdapter::the().has_queued_packets())
|
||||
return true;
|
||||
if (auto* e1000 = E1000NetworkAdapter::the()) {
|
||||
|
|
|
@ -162,7 +162,8 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
|
|||
m_state = State::Connecting;
|
||||
|
||||
if (should_block == ShouldBlock::Yes) {
|
||||
current->block<Thread::ConnectBlocker>(description);
|
||||
if (current->block<Thread::ConnectBlocker>(description) == Thread::BlockResult::InterruptedBySignal)
|
||||
return KResult(-EINTR);
|
||||
ASSERT(is_connected());
|
||||
return KSuccess;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue