From 52367772c8183c703ec320a74a6e3cd8aada3739 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Sun, 14 Jul 2019 22:01:15 +0200 Subject: [PATCH] daemon: add creation timestamp to GameModeClient Record the time a client was created, i.e. registered, in the GameModeClient struct and add a getter for it. (Alex Smith: Fixed up function documentation comments) --- daemon/gamemode-context.c | 21 +++++++++++++++++++++ daemon/gamemode.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/daemon/gamemode-context.c b/daemon/gamemode-context.c index 6e23116..e0351d6 100644 --- a/daemon/gamemode-context.c +++ b/daemon/gamemode-context.c @@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include /* TODO: Move usage to gamemode-dbus.c */ #include @@ -58,6 +59,7 @@ struct GameModeClient { pid_t pid; /**< Process ID */ struct GameModeClient *next; /**refcount = ATOMIC_VAR_INIT(1); strncpy(ret->executable, executable, PATH_MAX - 1); + return ret; } @@ -714,6 +726,15 @@ const char *game_mode_client_get_executable(GameModeClient *client) return client->executable; } +/** + * The time that game mode was requested for the client. + */ +uint64_t game_mode_client_get_timestamp(GameModeClient *client) +{ + assert(client != NULL); + return (uint64_t)client->timestamp; +} + /* Internal refresh config function (assumes no contention with reaper thread) */ static void game_mode_reload_config_internal(GameModeContext *self) { diff --git a/daemon/gamemode.h b/daemon/gamemode.h index 27151fa..78418f0 100644 --- a/daemon/gamemode.h +++ b/daemon/gamemode.h @@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once #include +#include #include #define INVALID_PROCFD -1 @@ -69,6 +70,11 @@ pid_t game_mode_client_get_pid(GameModeClient *client); */ const char *game_mode_client_get_executable(GameModeClient *client); +/** + * The time that game mode was requested for the client. + */ +u_int64_t game_mode_client_get_timestamp(GameModeClient *client); + /** * Return the singleton instance */