mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +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:
parent
66e5d0bdf3
commit
1d03391488
2 changed files with 3 additions and 0 deletions
|
@ -63,6 +63,7 @@ RefPtr<Socket> Socket::accept()
|
||||||
#endif
|
#endif
|
||||||
auto client = m_pending.take_first();
|
auto client = m_pending.take_first();
|
||||||
ASSERT(!client->is_connected());
|
ASSERT(!client->is_connected());
|
||||||
|
client->m_acceptor_pid = m_origin_pid;
|
||||||
client->set_setup_state(SetupState::Completed);
|
client->set_setup_state(SetupState::Completed);
|
||||||
client->m_connected = true;
|
client->m_connected = true;
|
||||||
client->m_role = Role::Accepted;
|
client->m_role = Role::Accepted;
|
||||||
|
|
|
@ -80,6 +80,7 @@ public:
|
||||||
KResult getsockopt(int level, int option, void*, socklen_t*);
|
KResult getsockopt(int level, int option, void*, socklen_t*);
|
||||||
|
|
||||||
pid_t origin_pid() const { return m_origin_pid; }
|
pid_t origin_pid() const { return m_origin_pid; }
|
||||||
|
pid_t acceptor_pid() const { return m_acceptor_pid; }
|
||||||
|
|
||||||
timeval receive_deadline() const { return m_receive_deadline; }
|
timeval receive_deadline() const { return m_receive_deadline; }
|
||||||
timeval send_deadline() const { return m_send_deadline; }
|
timeval send_deadline() const { return m_send_deadline; }
|
||||||
|
@ -111,6 +112,7 @@ private:
|
||||||
|
|
||||||
Lock m_lock { "Socket" };
|
Lock m_lock { "Socket" };
|
||||||
pid_t m_origin_pid { 0 };
|
pid_t m_origin_pid { 0 };
|
||||||
|
pid_t m_acceptor_pid { 0 };
|
||||||
int m_domain { 0 };
|
int m_domain { 0 };
|
||||||
int m_type { 0 };
|
int m_type { 0 };
|
||||||
int m_protocol { 0 };
|
int m_protocol { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue