From d99af407959c626af8aaaa8efc94665dfaafd86d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 2 Jul 2019 17:23:10 +0200 Subject: [PATCH] daemon: add game_mode_client_ref Now that GameModeClient is reference counted, the counterpart to game_mode_client_unref is also needed. --- daemon/gamemode-context.c | 8 ++++++++ daemon/gamemode.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/daemon/gamemode-context.c b/daemon/gamemode-context.c index 3108e70..d04fdcc 100644 --- a/daemon/gamemode-context.c +++ b/daemon/gamemode-context.c @@ -638,6 +638,14 @@ void game_mode_client_unref(GameModeClient *client) free(client); } +void game_mode_client_ref(GameModeClient *client) +{ + if (!client) { + return; + } + atomic_fetch_add_explicit(&client->refcount, 1, memory_order_seq_cst); +} + /* 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 03d9822..3901be8 100644 --- a/daemon/gamemode.h +++ b/daemon/gamemode.h @@ -54,6 +54,11 @@ typedef struct GameModeClient GameModeClient; */ void game_mode_client_unref(GameModeClient *client); +/** + * Increment the usage count of client. + */ +void game_mode_client_ref(GameModeClient *client); + /** * Return the singleton instance */