diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-03 20:15:54 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-03 20:15:54 +0200 |
commit | 03da7046bda1c2ff67305a8d9eb178d69dac46f8 (patch) | |
tree | 40ea45b2e6e7a86fe0a2f87c40159a674f502e47 /Kernel/Scheduler.cpp | |
parent | 9f633a1871ac5dbf21fca0a6d1cfd41d4084ca4c (diff) | |
download | serenity-03da7046bda1c2ff67305a8d9eb178d69dac46f8.zip |
Kernel: Prepare Socket for becoming a File.
Make the Socket functions take a FileDescriptor& rather than a socket role
throughout the code. Also change threads to block on a FileDescriptor,
rather than either an fd index or a Socket.
Diffstat (limited to 'Kernel/Scheduler.cpp')
-rw-r--r-- | Kernel/Scheduler.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index a92e57041f..3ee614533b 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -88,35 +88,35 @@ bool Scheduler::pick_next() } if (thread.state() == Thread::BlockedRead) { - ASSERT(thread.m_blocked_fd != -1); + ASSERT(thread.m_blocked_descriptor); // FIXME: Block until the amount of data wanted is available. - if (process.m_fds[thread.m_blocked_fd].descriptor->can_read()) + if (thread.m_blocked_descriptor->can_read()) thread.unblock(); return IterationDecision::Continue; } if (thread.state() == Thread::BlockedWrite) { - ASSERT(thread.m_blocked_fd != -1); - if (process.m_fds[thread.m_blocked_fd].descriptor->can_write()) + ASSERT(thread.m_blocked_descriptor != -1); + if (thread.m_blocked_descriptor->can_write()) thread.unblock(); return IterationDecision::Continue; } if (thread.state() == Thread::BlockedConnect) { - ASSERT(thread.m_blocked_socket); - if (thread.m_blocked_socket->is_connected()) + auto& descriptor = *thread.m_blocked_descriptor; + auto& socket = *descriptor.socket(); + if (socket.is_connected()) thread.unblock(); return IterationDecision::Continue; } if (thread.state() == Thread::BlockedReceive) { - ASSERT(thread.m_blocked_socket); - auto& socket = *thread.m_blocked_socket; + auto& descriptor = *thread.m_blocked_descriptor; + auto& socket = *descriptor.socket(); // FIXME: Block until the amount of data wanted is available. bool timed_out = now_sec > socket.receive_deadline().tv_sec || (now_sec == socket.receive_deadline().tv_sec && now_usec >= socket.receive_deadline().tv_usec); - if (timed_out || socket.can_read(SocketRole::None)) { + if (timed_out || descriptor.can_read()) { thread.unblock(); - thread.m_blocked_socket = nullptr; return IterationDecision::Continue; } return IterationDecision::Continue; |