1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:28:12 +00:00

Net: Store an acceptor PID alongside the origin PID in a socket

* The origin PID is the PID of the process that created this socket,
  either explicitly by calling socket(), or implicitly by accepting
  a TCP connection. Note that accepting a local socket connection
  does not create a new socket, it reuses the one connect() was
  called on, so for accepted local sockets the origin PID points
  to the connecting process.

* The acceptor PID is the PID of the process that accept()ed this
  socket. For accepted TCP sockets, this is the same as origin PID.
This commit is contained in:
Sergey Bugaev 2019-08-10 19:03:34 +03:00 committed by Andreas Kling
parent 66e5d0bdf3
commit 1d03391488
2 changed files with 3 additions and 0 deletions

View file

@ -63,6 +63,7 @@ RefPtr<Socket> Socket::accept()
#endif
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;