From b0acaaa22c12a56159a0971cc8fae22bf2c242d8 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Thu, 11 Feb 2016 00:40:29 +0100 Subject: [PATCH] Correctly store file descriptor from logind (#94070) The code had the issue that the file descriptor would be first stored, but then automatically cleaned up as it was only peeked from the list. Simplify this to check the length and then get the single file descriptor explictly. Signed-off-by: Benjamin Berg --- src/pk-engine.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/pk-engine.c b/src/pk-engine.c index 4cf3880..b326a0d 100644 --- a/src/pk-engine.c +++ b/src/pk-engine.c @@ -275,8 +275,6 @@ static void pk_engine_inhibit (PkEngine *engine) { #ifdef HAVE_SYSTEMD - const gint *fd_list; - gint fd_list_len = 0; g_autoptr(GError) error = NULL; g_autoptr(GUnixFDList) out_fd_list = NULL; g_autoptr(GVariant) res = NULL; @@ -311,12 +309,11 @@ pk_engine_inhibit (PkEngine *engine) } /* keep fd as cookie */ - fd_list = g_unix_fd_list_peek_fds (out_fd_list, &fd_list_len); - if (fd_list_len != 1) { + if (g_unix_fd_list_get_length (out_fd_list) != 1) { g_warning ("invalid response from logind"); return; } - engine->priv->logind_fd = fd_list[0]; + engine->priv->logind_fd = g_unix_fd_list_get (out_fd_list, 0, NULL); g_debug ("opened logind fd %i", engine->priv->logind_fd); #endif } -- 2.7.0