[gnome-software] Remove g_source_set_name_by_id calls



commit 29691f818ed6d386a2879c685c0c37d657e0dcc0
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Sep 15 22:45:50 2014 +0200

    Remove g_source_set_name_by_id calls
    
    It turns out to have been a major contributor to hard-to-debug
    gnome-software crashes. Unlike the rest of GSource, g_source_set_name /
    g_source_set_name_by_id are not threadsafe and calling them from a
    worker thread can lead to double frees and / or trashed heap.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=736683

 src/gs-app-addon-row.c   |    5 +----
 src/gs-app-tile.c        |    5 +----
 src/gs-app.c             |    4 +---
 src/gs-feature-tile.c    |    5 +----
 src/gs-plugin-loader.c   |    7 ++-----
 src/gs-plugin.c          |    8 ++------
 src/gs-popular-tile.c    |    5 +----
 src/gs-shell-details.c   |    5 +----
 src/gs-shell-installed.c |    5 +----
 src/gs-update-monitor.c  |    7 -------
 src/gs-utils.c           |    2 --
 11 files changed, 11 insertions(+), 47 deletions(-)
---
diff --git a/src/gs-app-addon-row.c b/src/gs-app-addon-row.c
index dc290dd..0bb6151 100644
--- a/src/gs-app-addon-row.c
+++ b/src/gs-app-addon-row.c
@@ -169,10 +169,7 @@ gs_app_addon_row_notify_props_changed_cb (GsApp *app,
                                           GParamSpec *pspec,
                                           GsAppAddonRow *row)
 {
-       guint id;
-
-       id = g_idle_add (gs_app_addon_row_refresh_idle, g_object_ref (row));
-       g_source_set_name_by_id (id, "[gnome-software] gs_app_addon_row_refresh_idle");
+       g_idle_add (gs_app_addon_row_refresh_idle, g_object_ref (row));
 }
 
 void
diff --git a/src/gs-app-tile.c b/src/gs-app-tile.c
index 056aa54..9bb8fd5 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -126,10 +126,7 @@ app_state_changed_idle (gpointer user_data)
 static void
 app_state_changed (GsApp *app, GParamSpec *pspec, GsAppTile *tile)
 {
-       guint id;
-
-       id = g_idle_add (app_state_changed_idle, g_object_ref (tile));
-       g_source_set_name_by_id (id, "[gnome-software] app_state_changed_idle");
+       g_idle_add (app_state_changed_idle, g_object_ref (tile));
 }
 
 void
diff --git a/src/gs-app.c b/src/gs-app.c
index 6c9deca..13b26c9 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -325,14 +325,12 @@ static void
 gs_app_queue_notify (GsApp *app, const gchar *property_name)
 {
        AppNotifyData *notify_data;
-       guint id;
 
        notify_data = g_new (AppNotifyData, 1);
        notify_data->app = g_object_ref (app);
        notify_data->property_name = g_strdup (property_name);
 
-       id = g_idle_add (notify_idle_cb, notify_data);
-       g_source_set_name_by_id (id, "[gnome-software] notify_idle_cb");
+       g_idle_add (notify_idle_cb, notify_data);
 }
 
 /**
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index f8d4f6d..6ad45e6 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -92,10 +92,7 @@ app_state_changed_idle (gpointer user_data)
 static void
 app_state_changed (GsApp *app, GParamSpec *pspec, GsFeatureTile *tile)
 {
-       guint id;
-
-       id = g_idle_add (app_state_changed_idle, g_object_ref (tile));
-       g_source_set_name_by_id (id, "[gnome-software] app_state_changed_idle");
+       g_idle_add (app_state_changed_idle, g_object_ref (tile));
 }
 
 void
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 76f0340..a1808f7 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -2104,14 +2104,12 @@ gs_plugin_loader_app_action_thread_cb (GTask *task,
        GPtrArray *addons;
        gboolean ret;
        guint i;
-       guint id;
 
        /* add to list */
        g_mutex_lock (&plugin_loader->priv->pending_apps_mutex);
        g_ptr_array_add (plugin_loader->priv->pending_apps, g_object_ref (state->app));
        g_mutex_unlock (&plugin_loader->priv->pending_apps_mutex);
-       id = g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
-       g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
+       g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
 
        /* perform action */
        ret = gs_plugin_loader_run_action (plugin_loader,
@@ -2149,8 +2147,7 @@ gs_plugin_loader_app_action_thread_cb (GTask *task,
        g_mutex_lock (&plugin_loader->priv->pending_apps_mutex);
        g_ptr_array_remove (plugin_loader->priv->pending_apps, state->app);
        g_mutex_unlock (&plugin_loader->priv->pending_apps_mutex);
-       id = g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
-       g_source_set_name_by_id (id, "[gnome-software] emit_pending_apps_idle");
+       g_idle_add (emit_pending_apps_idle, g_object_ref (plugin_loader));
 }
 
 static gboolean
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 53ad8c6..d7411e5 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -272,15 +272,13 @@ void
 gs_plugin_status_update (GsPlugin *plugin, GsApp *app, GsPluginStatus status)
 {
        GsPluginStatusHelper *helper;
-       guint id;
 
        helper = g_slice_new0 (GsPluginStatusHelper);
        helper->plugin = plugin;
        helper->status = status;
        if (app != NULL)
                helper->app = g_object_ref (app);
-       id = g_idle_add (gs_plugin_status_update_cb, helper);
-       g_source_set_name_by_id (id, "[gnome-software] gs_plugin_status_update_cb");
+       g_idle_add (gs_plugin_status_update_cb, helper);
 }
 
 /**
@@ -300,9 +298,7 @@ gs_plugin_updates_changed_cb (gpointer user_data)
 void
 gs_plugin_updates_changed (GsPlugin *plugin)
 {
-       guint id;
-       id = g_idle_add (gs_plugin_updates_changed_cb, plugin);
-       g_source_set_name_by_id (id, "[gnome-software] gs_plugin_updates_changed_cb");
+       g_idle_add (gs_plugin_updates_changed_cb, plugin);
 }
 
 /* vim: set noexpandtab: */
diff --git a/src/gs-popular-tile.c b/src/gs-popular-tile.c
index 712a08f..e26e006 100644
--- a/src/gs-popular-tile.c
+++ b/src/gs-popular-tile.c
@@ -108,10 +108,7 @@ app_state_changed_idle (gpointer user_data)
 static void
 app_state_changed (GsApp *app, GParamSpec *pspec, GsPopularTile *tile)
 {
-       guint id;
-
-       id = g_idle_add (app_state_changed_idle, g_object_ref (tile));
-       g_source_set_name_by_id (id, "[gnome-software] app_state_changed_idle");
+       g_idle_add (app_state_changed_idle, g_object_ref (tile));
 }
 
 void
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 06d7ca9..f7140f3 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -291,10 +291,7 @@ gs_shell_details_notify_state_changed_cb (GsApp *app,
                                          GParamSpec *pspec,
                                          GsShellDetails *shell_details)
 {
-       guint id;
-
-       id = g_idle_add (gs_shell_details_switch_to_idle, g_object_ref (shell_details));
-       g_source_set_name_by_id (id, "[gnome-software] gs_shell_details_switch_to_idle");
+       g_idle_add (gs_shell_details_switch_to_idle, g_object_ref (shell_details));
 }
 
 static void
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index 8dd2d03..46fb5e0 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -219,10 +219,7 @@ gs_shell_installed_notify_state_changed_cb (GsApp *app,
                                            GParamSpec *pspec,
                                            GsShellInstalled *shell)
 {
-       guint id;
-
-       id = g_idle_add (gs_shell_installed_invalidate_sort_idle, g_object_ref (shell));
-       g_source_set_name_by_id (id, "[gnome-software] gs_shell_installed_invalidate_sort_idle");
+       g_idle_add (gs_shell_installed_invalidate_sort_idle, g_object_ref (shell));
 }
 
 static void selection_changed (GsShellInstalled *shell);
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index 379a137..6693b79 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -94,7 +94,6 @@ notify_offline_update_available (GsUpdateMonitor *monitor)
 
        /* rate limit update notifications to once per hour */
        monitor->reenable_offline_update_id = g_timeout_add_seconds (3600, 
reenable_offline_update_notification, monitor);
-       g_source_set_name_by_id (monitor->reenable_offline_update_id, "[gnome-software] 
reenable_offline_update_notification");
 
        title = _("Software Updates Available");
        body = _("Important OS and application updates are ready to be installed");
@@ -494,8 +493,6 @@ start_hourly_checks_cb (gpointer data)
 
        monitor->check_hourly_id =
                g_timeout_add_seconds (3600, check_hourly_cb, monitor);
-       g_source_set_name_by_id (monitor->check_hourly_id,
-                                "[gnome-software] check_hourly_cb");
 
        monitor->start_hourly_checks_id = 0;
        return G_SOURCE_REMOVE;
@@ -534,8 +531,6 @@ gs_update_monitor_init (GsUpdateMonitor *monitor)
 
        monitor->check_offline_update_id = 
                g_timeout_add_seconds (15, check_offline_update_cb, monitor);
-       g_source_set_name_by_id (monitor->check_offline_update_id,
-                                "[gnome-software] check_offline_update_cb");
 
        monitor->settings = g_settings_new ("org.gnome.software");
        g_settings_get (monitor->settings, "check-timestamp", "x", &tmp);
@@ -543,8 +538,6 @@ gs_update_monitor_init (GsUpdateMonitor *monitor)
 
        monitor->start_hourly_checks_id =
                g_timeout_add_seconds (60, start_hourly_checks_cb, monitor);
-       g_source_set_name_by_id (monitor->start_hourly_checks_id,
-                                "[gnome-software] start_hourly_checks_cb");
 
        monitor->cancellable = g_cancellable_new ();
        monitor->task = pk_task_new ();
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 37818a0..252a9ab 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -63,7 +63,6 @@ start_spinning (gpointer data)
        gtk_widget_set_opacity (spinner, 0);
        gtk_spinner_start (GTK_SPINNER (spinner));
        id = g_timeout_add (100, fade_in, spinner);
-       g_source_set_name_by_id (id, "[gnome-software] fade_in");
        g_object_set_data_full (G_OBJECT (spinner), "fade-timeout",
                                GUINT_TO_POINTER (id), remove_source);
 
@@ -85,7 +84,6 @@ gs_start_spinner (GtkSpinner *spinner)
 
        gtk_widget_set_opacity (GTK_WIDGET (spinner), 0);
        id = g_timeout_add (SPINNER_DELAY, start_spinning, spinner);
-       g_source_set_name_by_id (id, "[gnome-software] start_spinning");
        g_object_set_data_full (G_OBJECT (spinner), "start-timeout",
                                GUINT_TO_POINTER (id), remove_source);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]