File PackageKit-fix-critical-on-idle-shutdown.patch of Package PackageKit.14884

From 0715a18bc5808419deeb067961ad76c50af4fb81 Mon Sep 17 00:00:00 2001
From: Kalev Lember <klember@redhat.com>
Date: Sun, 23 Sep 2018 00:02:15 +0200
Subject: [PATCH] main: Fix critical on idle shutdown

When doing the idle shutdown, the shutdown callback removes the shutdown
idle source from the main loop. Move things around a bit so that this
doesn't trigger a critical when cleaning up the same source at the end
of main().

(packagekitd:9749): GLib-CRITICAL **: 23:51:30.619: Source ID 13 was not found when attempting to remove it
---
 src/pk-main.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/pk-main.c b/src/pk-main.c
index d8bdca935..7a0bbd199 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -94,6 +94,7 @@ main (int argc, char *argv[])
 {
 	GMainLoop *loop = NULL;
 	GOptionContext *context;
+	PkMainHelper helper;
 	gboolean ret = TRUE;
 	gboolean disable_timer = FALSE;
 	gboolean version = FALSE;
@@ -101,7 +102,6 @@ main (int argc, char *argv[])
 	gboolean immediate_exit = FALSE;
 	gboolean keep_environment = FALSE;
 	gint exit_idle_time;
-	guint timer_id = 0;
 	g_autoptr(GError) error = NULL;
 	g_autofree gchar *backend_name = NULL;
 	g_autofree gchar *conf_filename = NULL;
@@ -229,13 +229,11 @@ main (int argc, char *argv[])
 
 	/* only poll when we are alive */
 	if (exit_idle_time > 0 && !disable_timer) {
-		PkMainHelper helper;
 		helper.engine = engine;
 		helper.exit_idle_time = exit_idle_time;
 		helper.loop = loop;
 		helper.timer_id = g_timeout_add_seconds (5, (GSourceFunc) pk_main_timeout_check_cb, &helper);
 		g_source_set_name_by_id (helper.timer_id, "[PkMain] main poll");
-		timer_id = helper.timer_id;
 	}
 
 	/* immediatly exit */
@@ -249,8 +247,8 @@ out:
 	syslog (LOG_DAEMON | LOG_DEBUG, "daemon quit");
 	closelog ();
 
-	if (timer_id > 0)
-		g_source_remove (timer_id);
+	if (helper.timer_id > 0)
+		g_source_remove (helper.timer_id);
 	if (loop != NULL)
 		g_main_loop_unref (loop);
 exit_program:
-- 
2.24.1

openSUSE Build Service is sponsored by