[gnome-software/wip/automatic-update-fixes: 85/92] plugin-loader: Schedule 'updates-changed' signal when received with no job running
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/automatic-update-fixes: 85/92] plugin-loader: Schedule 'updates-changed' signal when received with no job running
- Date: Thu, 7 Jul 2022 08:19:24 +0000 (UTC)
commit 680726fa2fa5b7f39aa86da05f161604a132085f
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 15 17:55:31 2022 +0200
plugin-loader: Schedule 'updates-changed' signal when received with no job running
This helps to avoid a race condition when a plugin calls
updates-changed at the end of the job, but the job is
finished before the callback gets called in the main thread.
lib/gs-plugin-loader.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index fc374256d..d728bfc5c 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1774,12 +1774,6 @@ gs_plugin_loader_job_actions_changed_delay_cb (gpointer user_data)
return FALSE;
}
-static void
-gs_plugin_loader_job_actions_changed_cb (GsPlugin *plugin, GsPluginLoader *plugin_loader)
-{
- plugin_loader->updates_changed_cnt++;
-}
-
static void
gs_plugin_loader_updates_changed (GsPluginLoader *plugin_loader)
{
@@ -1791,6 +1785,20 @@ gs_plugin_loader_updates_changed (GsPluginLoader *plugin_loader)
g_object_ref (plugin_loader));
}
+static void
+gs_plugin_loader_job_updates_changed_cb (GsPlugin *plugin,
+ GsPluginLoader *plugin_loader)
+{
+ plugin_loader->updates_changed_cnt++;
+
+ /* Schedule emit of updates changed when no job is active.
+ This helps to avoid a race condition when a plugin calls
+ updates-changed at the end of the job, but the job is
+ finished before the callback gets called in the main thread. */
+ if (!g_atomic_int_get (&plugin_loader->active_jobs))
+ gs_plugin_loader_updates_changed (plugin_loader);
+}
+
static gboolean
gs_plugin_loader_reload_delay_cb (gpointer user_data)
{
@@ -1849,7 +1857,7 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
return;
}
g_signal_connect (plugin, "updates-changed",
- G_CALLBACK (gs_plugin_loader_job_actions_changed_cb),
+ G_CALLBACK (gs_plugin_loader_job_updates_changed_cb),
plugin_loader);
g_signal_connect (plugin, "reload",
G_CALLBACK (gs_plugin_loader_reload_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]