Kernel: Remove ioctl for getting a socket peer's PID.
Now that everything is nice and mature, the WindowServer can just use the client PID it receives in the Greeting message, and we can get rid of this hacky ioctl. :^)
This commit is contained in:
parent
bc1da7f1fd
commit
367bb9e4eb
Notes:
sideshowbarker
2024-07-19 14:59:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/367bb9e4eb3
4 changed files with 6 additions and 19 deletions
|
@ -1939,13 +1939,6 @@ int Process::sys$ioctl(int fd, unsigned request, unsigned arg)
|
|||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
if (descriptor->is_socket() && request == 413) {
|
||||
auto* pid = (pid_t*)arg;
|
||||
if (!validate_write_typed(pid))
|
||||
return -EFAULT;
|
||||
*pid = descriptor->socket()->origin_pid();
|
||||
return 0;
|
||||
}
|
||||
if (!descriptor->is_device())
|
||||
return -ENOTTY;
|
||||
return descriptor->device()->ioctl(*this, request, arg);
|
||||
|
|
|
@ -40,9 +40,6 @@ WSClientConnection::WSClientConnection(int fd)
|
|||
static int s_next_client_id = 0;
|
||||
m_client_id = ++s_next_client_id;
|
||||
|
||||
int rc = ioctl(m_fd, 413, (int)&m_pid);
|
||||
ASSERT(rc == 0);
|
||||
|
||||
if (!s_connections)
|
||||
s_connections = new HashMap<int, WSClientConnection*>;
|
||||
s_connections->set(m_client_id, this);
|
||||
|
@ -86,13 +83,6 @@ void WSClientConnection::post_message(const WSAPI_ServerMessage& message)
|
|||
ASSERT(nwritten == sizeof(message));
|
||||
}
|
||||
|
||||
RetainPtr<GraphicsBitmap> WSClientConnection::create_shared_bitmap(GraphicsBitmap::Format format, const Size& size)
|
||||
{
|
||||
auto shared_buffer = SharedBuffer::create(m_pid, size.area() * sizeof(RGBA32));
|
||||
ASSERT(shared_buffer);
|
||||
return GraphicsBitmap::create_with_shared_buffer(format, *shared_buffer, size);
|
||||
}
|
||||
|
||||
void WSClientConnection::on_message(WSMessage& message)
|
||||
{
|
||||
if (message.is_client_request()) {
|
||||
|
|
|
@ -22,7 +22,6 @@ public:
|
|||
static void for_each_client(Function<void(WSClientConnection&)>);
|
||||
|
||||
void post_message(const WSAPI_ServerMessage&);
|
||||
RetainPtr<GraphicsBitmap> create_shared_bitmap(GraphicsBitmap::Format, const Size&);
|
||||
|
||||
int client_id() const { return m_client_id; }
|
||||
WSMenuBar* app_menubar() { return m_app_menubar.ptr(); }
|
||||
|
@ -32,6 +31,8 @@ public:
|
|||
|
||||
bool is_showing_modal_window() const;
|
||||
|
||||
void set_client_pid(pid_t pid) { m_pid = pid; }
|
||||
|
||||
template<typename Matching, typename Callback> void for_each_window_matching(Matching, Callback);
|
||||
template<typename Callback> void for_each_window(Callback);
|
||||
|
||||
|
@ -66,7 +67,7 @@ private:
|
|||
|
||||
int m_client_id { 0 };
|
||||
int m_fd { -1 };
|
||||
pid_t m_pid { 0 };
|
||||
pid_t m_pid { -1 };
|
||||
|
||||
HashMap<int, OwnPtr<WSWindow>> m_windows;
|
||||
HashMap<int, OwnPtr<WSMenuBar>> m_menubars;
|
||||
|
|
|
@ -257,6 +257,9 @@ void WSMessageLoop::on_receive_from_client(int client_id, const WSAPI_ClientMess
|
|||
|
||||
WSClientConnection& client = *WSClientConnection::from_client_id(client_id);
|
||||
switch (message.type) {
|
||||
case WSAPI_ClientMessage::Type::Greeting:
|
||||
client.set_client_pid(message.greeting.client_pid);
|
||||
break;
|
||||
case WSAPI_ClientMessage::Type::CreateMenubar:
|
||||
post_message(client, make<WSAPICreateMenubarRequest>(client_id));
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue