[gvfs] client: Don't user g_source_remove() on non-default main context
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] client: Don't user g_source_remove() on non-default main context
- Date: Thu, 3 Oct 2013 11:41:15 +0000 (UTC)
commit 33df4211825ad9ef36272a3e5cf987ea8f7cfe01
Author: Alexander Larsson <alexl redhat com>
Date: Thu Oct 3 13:39:13 2013 +0200
client: Don't user g_source_remove() on non-default main context
We created a GSource, attached it to a non-default main context and
then removed it via g_source_remove, which removed the source with the
same id on the main context, which typically was the X fd, causing
everything to stop working!
Non-default main contexts must use g_source_destroy()
https://bugzilla.gnome.org/show_bug.cgi?id=708744
client/gdaemonfileenumerator.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/client/gdaemonfileenumerator.c b/client/gdaemonfileenumerator.c
index f012837..219bfe6 100644
--- a/client/gdaemonfileenumerator.c
+++ b/client/gdaemonfileenumerator.c
@@ -61,7 +61,7 @@ struct _GDaemonFileEnumerator
GSimpleAsyncResult *async_res;
GMainLoop *next_files_mainloop;
GMainContext *next_files_context;
- guint next_files_sync_timeout_tag;
+ GSource *next_files_sync_timeout_source;
GMutex next_files_mutex;
GFileAttributeMatcher *matcher;
@@ -102,7 +102,7 @@ free_info_list (GList *infos)
g_list_free_full (infos, g_object_unref);
}
-static guint
+static GSource *
add_timeout_for_context (GMainContext *context,
guint32 interval,
GSourceFunc function,
@@ -116,10 +116,9 @@ add_timeout_for_context (GMainContext *context,
source = g_timeout_source_new (interval);
g_source_set_callback (source, function, data, NULL);
- id = g_source_attach (source, context);
- g_source_unref (source);
+ g_source_attach (source, context);
- return id;
+ return source;
}
@@ -486,7 +485,7 @@ g_daemon_file_enumerator_next_file (GFileEnumerator *enumerator,
{
GDaemonFileEnumerator *daemon = G_DAEMON_FILE_ENUMERATOR (enumerator);
GFileInfo *info;
-
+
if (daemon->sync_connection == NULL)
{
/* The enumerator was initialized by an async call, so responses will
@@ -509,14 +508,15 @@ g_daemon_file_enumerator_next_file (GFileEnumerator *enumerator,
g_mutex_unlock (&daemon->next_files_mutex);
g_main_context_push_thread_default (daemon->next_files_context);
- daemon->next_files_sync_timeout_tag = add_timeout_for_context (daemon->next_files_context,
- G_VFS_DBUS_TIMEOUT_MSECS,
- sync_timeout, daemon);
+ daemon->next_files_sync_timeout_source = add_timeout_for_context (daemon->next_files_context,
+ G_VFS_DBUS_TIMEOUT_MSECS,
+ sync_timeout, daemon);
g_main_loop_run (daemon->next_files_mainloop);
g_main_context_pop_thread_default (daemon->next_files_context);
g_mutex_lock (&daemon->next_files_mutex);
- g_source_remove (daemon->next_files_sync_timeout_tag);
+ g_source_destroy (daemon->next_files_sync_timeout_source);
+ g_source_unref (daemon->next_files_sync_timeout_source);
g_main_loop_unref (daemon->next_files_mainloop);
daemon->next_files_mainloop = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]