1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

Kernel: Hold socket back from accept() until it's fully set up

This commit is contained in:
Conrad Pankoff 2019-09-08 17:18:28 +10:00 committed by Andreas Kling
parent d53c9d4416
commit 72f728b0d6
3 changed files with 21 additions and 2 deletions

View file

@ -79,14 +79,27 @@ RefPtr<TCPSocket> TCPSocket::create_client(const IPv4Address& new_local_address,
client->set_peer_address(new_peer_address);
client->set_peer_port(new_peer_port);
client->set_direction(Direction::Incoming);
client->set_originator(*this);
queue_connection_from(client);
m_pending_release_for_accept.set(tuple, client);
sockets_by_tuple().resource().set(tuple, client);
return from_tuple(tuple);
}
void TCPSocket::release_to_originator()
{
ASSERT(!!m_originator);
m_originator->release_for_accept(this);
}
void TCPSocket::release_for_accept(RefPtr<TCPSocket> socket)
{
ASSERT(m_pending_release_for_accept.contains(socket->tuple()));
m_pending_release_for_accept.remove(socket->tuple());
queue_connection_from(*socket);
}
TCPSocket::TCPSocket(int protocol)
: IPv4Socket(SOCK_STREAM, protocol)
{