summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKalev Lember <klember@redhat.com>2018-09-23 00:02:15 +0200
committerKalev Lember <klember@redhat.com>2018-09-23 00:08:29 +0200
commit0715a18bc5808419deeb067961ad76c50af4fb81 (patch)
tree7cd340489937b866e722259e8ede9f7a30dcd028 /src
parentd640d2555a87fcb85747b4feb1ac9016353d8754 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/pk-main.c8
1 files 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: