[gnome-software/wip/automatic-update-fixes: 18/25] 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: 18/25] plugin-loader: Schedule 'updates-changed' signal when received with no job running
- Date: Tue, 21 Jun 2022 16:33:14 +0000 (UTC)
commit 50712393685cfb5f374d48a0a469af70914f124a
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 457a7f806..14bf46440 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1782,12 +1782,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)
{
@@ -1799,6 +1793,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)
{
@@ -1857,7 +1865,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]