diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-31 09:24:46 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-31 09:29:27 +0100 |
commit | 1b5be4a342e0dc0ec4b45849fff92f61d573af36 (patch) | |
tree | 74c23f787baddced55be2cea44d269119810e277 /Userland | |
parent | 50092ea0ca37f0818d07c25651f2b5ad0f0acc2a (diff) | |
download | serenity-1b5be4a342e0dc0ec4b45849fff92f61d573af36.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibIPC/ClientConnection.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibIPC/Connection.h | 15 | ||||
-rw-r--r-- | Userland/Libraries/LibIPC/ServerConnection.h | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibImageDecoderClient/Client.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebContentClient.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/ImageDecoder/ClientConnection.cpp | 5 | ||||
-rw-r--r-- | Userland/Services/ImageDecoder/ImageDecoderServer.ipc | 2 | ||||
-rw-r--r-- | Userland/Services/WebContent/ClientConnection.cpp | 5 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebContentServer.ipc | 2 |
9 files changed, 11 insertions, 39 deletions
diff --git a/Userland/Libraries/LibIPC/ClientConnection.h b/Userland/Libraries/LibIPC/ClientConnection.h index ea69210557..bca77f3b58 100644 --- a/Userland/Libraries/LibIPC/ClientConnection.h +++ b/Userland/Libraries/LibIPC/ClientConnection.h @@ -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: diff --git a/Userland/Libraries/LibIPC/Connection.h b/Userland/Libraries/LibIPC/Connection.h index 27afd16626..899eaa6412 100644 --- a/Userland/Libraries/LibIPC/Connection.h +++ b/Userland/Libraries/LibIPC/Connection.h @@ -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 }; }; } diff --git a/Userland/Libraries/LibIPC/ServerConnection.h b/Userland/Libraries/LibIPC/ServerConnection.h index f90fddccfc..5912bc006b 100644 --- a/Userland/Libraries/LibIPC/ServerConnection.h +++ b/Userland/Libraries/LibIPC/ServerConnection.h @@ -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; } diff --git a/Userland/Libraries/LibImageDecoderClient/Client.cpp b/Userland/Libraries/LibImageDecoderClient/Client.cpp index e9c2a25350..cddd753f37 100644 --- a/Userland/Libraries/LibImageDecoderClient/Client.cpp +++ b/Userland/Libraries/LibImageDecoderClient/Client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,9 +37,8 @@ Client::Client() void Client::handshake() { - auto response = send_sync<Messages::ImageDecoderServer::Greet>(getpid()); + auto response = send_sync<Messages::ImageDecoderServer::Greet>(); set_my_client_id(response->client_id()); - set_server_pid(response->server_pid()); } void Client::handle(const Messages::ImageDecoderClient::Dummy&) diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp index 087f9f9c9e..99b9dd87ab 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.cpp +++ b/Userland/Libraries/LibWeb/WebContentClient.cpp @@ -45,9 +45,8 @@ void WebContentClient::die() void WebContentClient::handshake() { - auto response = send_sync<Messages::WebContentServer::Greet>(getpid()); + auto response = send_sync<Messages::WebContentServer::Greet>(); set_my_client_id(response->client_id()); - set_server_pid(response->server_pid()); } void WebContentClient::handle(const Messages::WebContentClient::DidPaint& message) diff --git a/Userland/Services/ImageDecoder/ClientConnection.cpp b/Userland/Services/ImageDecoder/ClientConnection.cpp index db8d663e2b..97fd11eb2f 100644 --- a/Userland/Services/ImageDecoder/ClientConnection.cpp +++ b/Userland/Services/ImageDecoder/ClientConnection.cpp @@ -51,10 +51,9 @@ void ClientConnection::die() exit(0); } -OwnPtr<Messages::ImageDecoderServer::GreetResponse> ClientConnection::handle(const Messages::ImageDecoderServer::Greet& message) +OwnPtr<Messages::ImageDecoderServer::GreetResponse> ClientConnection::handle(const Messages::ImageDecoderServer::Greet&) { - set_client_pid(message.client_pid()); - return make<Messages::ImageDecoderServer::GreetResponse>(client_id(), getpid()); + return make<Messages::ImageDecoderServer::GreetResponse>(client_id()); } OwnPtr<Messages::ImageDecoderServer::DecodeImageResponse> ClientConnection::handle(const Messages::ImageDecoderServer::DecodeImage& message) diff --git a/Userland/Services/ImageDecoder/ImageDecoderServer.ipc b/Userland/Services/ImageDecoder/ImageDecoderServer.ipc index 64ebc04b26..c8d393ad4d 100644 --- a/Userland/Services/ImageDecoder/ImageDecoderServer.ipc +++ b/Userland/Services/ImageDecoder/ImageDecoderServer.ipc @@ -1,6 +1,6 @@ endpoint ImageDecoderServer = 7001 { - Greet(i32 client_pid) => (i32 client_id, i32 server_pid) + Greet() => (i32 client_id) DecodeImage(Core::AnonymousBuffer data) => (bool is_animated, u32 loop_count, Vector<Gfx::ShareableBitmap> bitmaps, Vector<u32> durations) } diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp index b41e35cb9b..b680fad970 100644 --- a/Userland/Services/WebContent/ClientConnection.cpp +++ b/Userland/Services/WebContent/ClientConnection.cpp @@ -76,10 +76,9 @@ const Web::Page& ClientConnection::page() const return m_page_host->page(); } -OwnPtr<Messages::WebContentServer::GreetResponse> ClientConnection::handle(const Messages::WebContentServer::Greet& message) +OwnPtr<Messages::WebContentServer::GreetResponse> ClientConnection::handle(const Messages::WebContentServer::Greet&) { - set_client_pid(message.client_pid()); - return make<Messages::WebContentServer::GreetResponse>(client_id(), getpid()); + return make<Messages::WebContentServer::GreetResponse>(client_id()); } void ClientConnection::handle(const Messages::WebContentServer::UpdateSystemTheme& message) diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index 81620f7ecf..d598c4ea92 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -1,6 +1,6 @@ endpoint WebContentServer = 89 { - Greet(i32 client_pid) => (i32 client_id, i32 server_pid) + Greet() => (i32 client_id) UpdateSystemTheme(Core::AnonymousBuffer theme_buffer) =| |