mirror of
https://github.com/RGBCube/serenity
synced 2025-07-05 08:57:35 +00:00
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.
This commit is contained in:
parent
9f633a1871
commit
03da7046bd
14 changed files with 118 additions and 115 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue