[gnome-software/gnome-3-12] plugin loader: Improve thread safety
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-12] plugin loader: Improve thread safety
- Date: Tue, 8 Apr 2014 12:43:43 +0000 (UTC)
commit 5d37bc079b7275657c8b59b0c7a3b89af65f1a2e
Author: Kalev Lember <kalevlember gmail com>
Date: Tue Apr 8 14:06:09 2014 +0200
plugin loader: Improve thread safety
Add missing locking to two places.
https://bugzilla.gnome.org/show_bug.cgi?id=727823
src/gs-plugin-loader.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index a825354..dc177fd 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2211,13 +2211,18 @@ load_install_queue (GsPluginLoader *plugin_loader, GError **error)
continue;
app = gs_app_new (names[i]);
gs_app_set_state (app, GS_APP_STATE_QUEUED);
+
+ g_mutex_lock (&plugin_loader->priv->app_cache_mutex);
g_hash_table_insert (plugin_loader->priv->app_cache,
g_strdup (gs_app_get_id (app)),
g_object_ref (app));
+ g_mutex_unlock (&plugin_loader->priv->app_cache_mutex);
+
g_mutex_lock (&plugin_loader->priv->pending_apps_mutex);
g_ptr_array_add (plugin_loader->priv->pending_apps,
g_object_ref (app));
g_mutex_unlock (&plugin_loader->priv->pending_apps_mutex);
+
g_debug ("adding pending app %s", gs_app_get_id (app));
gs_plugin_add_app (&list, app);
g_object_unref (app);
@@ -2447,6 +2452,7 @@ gs_plugin_loader_get_state_for_app (GsPluginLoader *plugin_loader, GsApp *app)
GsPluginLoaderPrivate *priv = plugin_loader->priv;
guint i;
+ g_mutex_lock (&plugin_loader->priv->pending_apps_mutex);
for (i = 0; i < priv->pending_apps->len; i++) {
tmp = g_ptr_array_index (priv->pending_apps, i);
if (g_strcmp0 (gs_app_get_id (tmp), gs_app_get_id (app)) == 0) {
@@ -2454,6 +2460,7 @@ gs_plugin_loader_get_state_for_app (GsPluginLoader *plugin_loader, GsApp *app)
break;
}
}
+ g_mutex_unlock (&plugin_loader->priv->pending_apps_mutex);
return state;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]