[gnome-software] plugin loader: Make gs_plugin_loader_get_event_default thread safe
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] plugin loader: Make gs_plugin_loader_get_event_default thread safe
- Date: Fri, 30 Nov 2018 16:03:32 +0000 (UTC)
commit 43ce7189db6d8b46dcb260bb080c7b36b928920f
Author: Kalev Lember <klember redhat com>
Date: Fri Nov 30 16:39:37 2018 +0100
plugin loader: Make gs_plugin_loader_get_event_default thread safe
We have to take a ref on the event while holding the lock, as otherwise
a plugin worker thread might destroy it (by adding a new event with the
same unique ID to the hash table) while we're processing it in the main
thread.
lib/gs-plugin-loader.c | 4 ++--
plugins/dummy/gs-self-test.c | 2 +-
src/gs-shell.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index afd36833..5f469262 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1903,7 +1903,7 @@ gs_plugin_loader_get_events (GsPluginLoader *plugin_loader)
* Gets an active plugin event where active means that it was not been
* already dismissed by the user.
*
- * Returns: a #GsPluginEvent, or %NULL for none
+ * Returns: (transfer full): a #GsPluginEvent, or %NULL for none
**/
GsPluginEvent *
gs_plugin_loader_get_event_default (GsPluginLoader *plugin_loader)
@@ -1922,7 +1922,7 @@ gs_plugin_loader_get_event_default (GsPluginLoader *plugin_loader)
continue;
}
if (!gs_plugin_event_has_flag (event, GS_PLUGIN_EVENT_FLAG_INVALID))
- return event;
+ return g_object_ref (event);
}
return NULL;
}
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 1708a0b5..87a35d0f 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -97,12 +97,12 @@ gs_plugins_dummy_install_func (GsPluginLoader *plugin_loader)
static void
gs_plugins_dummy_error_func (GsPluginLoader *plugin_loader)
{
- GsPluginEvent *event;
const GError *app_error;
gboolean ret;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) events = NULL;
g_autoptr(GsApp) app = NULL;
+ g_autoptr(GsPluginEvent) event = NULL;
g_autoptr(GsPluginJob) plugin_job = NULL;
/* drop all caches */
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 1bf72ef1..85d66a31 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1861,9 +1861,9 @@ gs_shell_show_event (GsShell *shell, GsPluginEvent *event)
static void
gs_shell_rescan_events (GsShell *shell)
{
- GsPluginEvent *event;
GsShellPrivate *priv = gs_shell_get_instance_private (shell);
GtkWidget *widget;
+ g_autoptr(GsPluginEvent) event = NULL;
/* find the first active event and show it */
event = gs_plugin_loader_get_event_default (priv->plugin_loader);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]