mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:47:35 +00:00
LibIPC: Stop exchanging client/server PIDs in greeting handshake
The PIDs were used for sharing shbufs between processes, but now that we have migrated to file descriptor passing, we no longer need to know the PID of the other side.
This commit is contained in:
parent
50092ea0ca
commit
1b5be4a342
9 changed files with 11 additions and 39 deletions
|
@ -45,7 +45,6 @@ public:
|
|||
{
|
||||
ASSERT(this->socket().is_connected());
|
||||
this->socket().on_ready_to_read = [this] { this->drain_messages_from_peer(); };
|
||||
this->initialize_peer_info();
|
||||
}
|
||||
|
||||
virtual ~ClientConnection() override
|
||||
|
@ -54,21 +53,18 @@ public:
|
|||
|
||||
void did_misbehave()
|
||||
{
|
||||
dbgln("{} (id={}, pid={}) misbehaved, disconnecting.", *this, m_client_id, client_pid());
|
||||
dbgln("{} (id={}) misbehaved, disconnecting.", *this, m_client_id);
|
||||
this->shutdown();
|
||||
}
|
||||
|
||||
void did_misbehave(const char* message)
|
||||
{
|
||||
dbgln("{} (id={}, pid={}) misbehaved ({}), disconnecting.", *this, m_client_id, client_pid(), message);
|
||||
dbgln("{} (id={}) misbehaved ({}), disconnecting.", *this, m_client_id, message);
|
||||
this->shutdown();
|
||||
}
|
||||
|
||||
int client_id() const { return m_client_id; }
|
||||
|
||||
pid_t client_pid() const { return this->peer_pid(); }
|
||||
void set_client_pid(pid_t pid) { this->set_peer_pid(pid); }
|
||||
|
||||
virtual void die() = 0;
|
||||
|
||||
private:
|
||||
|
|
|
@ -60,8 +60,6 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
pid_t peer_pid() const { return m_peer_pid; }
|
||||
|
||||
template<typename MessageType>
|
||||
OwnPtr<MessageType> wait_for_specific_message()
|
||||
{
|
||||
|
@ -141,7 +139,6 @@ public:
|
|||
|
||||
protected:
|
||||
Core::LocalSocket& socket() { return *m_socket; }
|
||||
void set_peer_pid(pid_t pid) { m_peer_pid = pid; }
|
||||
|
||||
template<typename MessageType, typename Endpoint>
|
||||
OwnPtr<MessageType> wait_for_specific_endpoint_message()
|
||||
|
@ -257,17 +254,6 @@ protected:
|
|||
}
|
||||
|
||||
protected:
|
||||
void initialize_peer_info()
|
||||
{
|
||||
ucred creds;
|
||||
socklen_t creds_size = sizeof(creds);
|
||||
if (getsockopt(this->socket().fd(), SOL_SOCKET, SO_PEERCRED, &creds, &creds_size) < 0) {
|
||||
// FIXME: We should handle this more gracefully.
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
m_peer_pid = creds.pid;
|
||||
}
|
||||
|
||||
LocalEndpoint& m_local_endpoint;
|
||||
NonnullRefPtr<Core::LocalSocket> m_socket;
|
||||
RefPtr<Core::Timer> m_responsiveness_timer;
|
||||
|
@ -275,7 +261,6 @@ protected:
|
|||
RefPtr<Core::Notifier> m_notifier;
|
||||
NonnullOwnPtrVector<Message> m_unprocessed_messages;
|
||||
ByteBuffer m_unprocessed_bytes;
|
||||
pid_t m_peer_pid { -1 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -45,15 +45,10 @@ public:
|
|||
}
|
||||
|
||||
ASSERT(this->socket().is_connected());
|
||||
|
||||
this->initialize_peer_info();
|
||||
}
|
||||
|
||||
virtual void handshake() = 0;
|
||||
|
||||
pid_t server_pid() const { return this->peer_pid(); }
|
||||
void set_server_pid(pid_t pid) { this->set_peer_pid(pid); }
|
||||
|
||||
void set_my_client_id(int id) { m_my_client_id = id; }
|
||||
int my_client_id() const { return m_my_client_id; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue