mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
Kernel: Delay moving accepted sockets to SetupState::Completed a bit
Make sure we don't move accepted sockets to the Completed setup state until we've actually constructed a FileDescription for them. This is important, since this state transition will trigger connect() to unblock on the client side, and the client may try writing to the socket right away. This makes DNS lookups way more reliable since we don't just fail to write() right after connect()ing to LookupServer sometimes. :^)
This commit is contained in:
parent
3aa27b5b0e
commit
9bb0374d7d
2 changed files with 3 additions and 1 deletions
|
@ -65,7 +65,6 @@ RefPtr<Socket> Socket::accept()
|
|||
auto client = m_pending.take_first();
|
||||
ASSERT(!client->is_connected());
|
||||
client->m_acceptor_pid = m_origin_pid;
|
||||
client->set_setup_state(SetupState::Completed);
|
||||
client->m_connected = true;
|
||||
client->m_role = Role::Accepted;
|
||||
return client;
|
||||
|
|
|
@ -2351,6 +2351,9 @@ int Process::sys$accept(int accepting_socket_fd, sockaddr* address, socklen_t* a
|
|||
// I'm not sure if this matches other systems but it makes sense to me.
|
||||
accepted_socket_description->set_blocking(accepting_socket_description->is_blocking());
|
||||
m_fds[accepted_socket_fd].set(move(accepted_socket_description), m_fds[accepting_socket_fd].flags);
|
||||
|
||||
// NOTE: Moving this state to Completed is what causes connect() to unblock on the client side.
|
||||
accepted_socket->set_setup_state(Socket::SetupState::Completed);
|
||||
return accepted_socket_fd;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue