From 1920a9f0d75fb0bc5e8949e1595f90570bc133b1 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 20 Jun 2023 20:13:16 +0100 Subject: [PATCH] ipc: Send less information when describing the client --- src/xrt/ipc/client/ipc_client_connection.c | 6 ++-- src/xrt/ipc/server/ipc_server_handler.c | 33 +++++++++++----------- src/xrt/ipc/shared/ipc_protocol.h | 9 ++++++ src/xrt/ipc/shared/proto.json | 12 ++++---- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/xrt/ipc/client/ipc_client_connection.c b/src/xrt/ipc/client/ipc_client_connection.c index ceadcc23c..193a3329a 100644 --- a/src/xrt/ipc/client/ipc_client_connection.c +++ b/src/xrt/ipc/client/ipc_client_connection.c @@ -289,13 +289,13 @@ ipc_client_connection_init(struct ipc_connection *ipc_c, return xret; } - struct ipc_app_state desc = {0}; + struct ipc_client_description desc = {0}; desc.info = *i_info; desc.pid = getpid(); // Extra info. - xret = ipc_call_system_set_client_info(ipc_c, &desc); + xret = ipc_call_instance_describe_client(ipc_c, &desc); if (xret != XRT_SUCCESS) { - IPC_ERROR(ipc_c, "Failed to set instance info!"); + IPC_ERROR(ipc_c, "Failed to set instance description!"); ipc_client_connection_fini(ipc_c); diff --git a/src/xrt/ipc/server/ipc_server_handler.c b/src/xrt/ipc/server/ipc_server_handler.c index 431eb7abc..ff30b4977 100644 --- a/src/xrt/ipc/server/ipc_server_handler.c +++ b/src/xrt/ipc/server/ipc_server_handler.c @@ -163,6 +163,23 @@ ipc_handle_instance_get_shm_fd(volatile struct ipc_client_state *ics, return XRT_SUCCESS; } +xrt_result_t +ipc_handle_instance_describe_client(volatile struct ipc_client_state *ics, + const struct ipc_client_description *client_desc) +{ + ics->client_state.info = client_desc->info; + ics->client_state.pid = client_desc->pid; + + IPC_INFO(ics->server, + "Client info\n" + "\tapplication_name: '%s'\n" + "\tpid: %i", + client_desc->info.application_name, // + client_desc->pid); // + + return XRT_SUCCESS; +} + xrt_result_t ipc_handle_system_compositor_get_info(volatile struct ipc_client_state *ics, struct xrt_system_compositor_info *out_info) @@ -946,22 +963,6 @@ ipc_handle_system_get_client_info(volatile struct ipc_client_state *_ics, return XRT_SUCCESS; } -xrt_result_t -ipc_handle_system_set_client_info(volatile struct ipc_client_state *ics, const struct ipc_app_state *client_desc) -{ - ics->client_state.info = client_desc->info; - ics->client_state.pid = client_desc->pid; - - IPC_INFO(ics->server, - "Client info\n" - "\tapplication_name: '%s'\n" - "\tpid: %i", - client_desc->info.application_name, // - client_desc->pid); // - - return XRT_SUCCESS; -} - xrt_result_t ipc_handle_system_get_clients(volatile struct ipc_client_state *_ics, struct ipc_client_list *list) { diff --git a/src/xrt/ipc/shared/ipc_protocol.h b/src/xrt/ipc/shared/ipc_protocol.h index 47c8bc299..b5727f922 100644 --- a/src/xrt/ipc/shared/ipc_protocol.h +++ b/src/xrt/ipc/shared/ipc_protocol.h @@ -274,6 +274,15 @@ struct ipc_shared_memory uint64_t startup_timestamp; }; +/*! + * Initial info from a client when it connects. + */ +struct ipc_client_description +{ + pid_t pid; + struct xrt_instance_info info; +}; + struct ipc_client_list { int32_t ids[IPC_MAX_CLIENTS]; diff --git a/src/xrt/ipc/shared/proto.json b/src/xrt/ipc/shared/proto.json index 3c59cc82b..7a75e8007 100644 --- a/src/xrt/ipc/shared/proto.json +++ b/src/xrt/ipc/shared/proto.json @@ -5,6 +5,12 @@ "out_handles": {"type": "xrt_shmem_handle_t"} }, + "instance_describe_client": { + "in": [ + {"name": "desc", "type": "struct ipc_client_description"} + ] + }, + "system_get_client_info": { "in": [ {"name": "id", "type": "uint32_t"} @@ -14,12 +20,6 @@ ] }, - "system_set_client_info": { - "in": [ - {"name": "desc", "type": "struct ipc_app_state"} - ] - }, - "system_get_clients": { "out": [ {"name": "clients", "type": "struct ipc_client_list"}