Commit ab278c00 authored by Ondrej Holy's avatar Ondrej Holy

gunixmounts: Prevent race when mtab file changed

mtab_file_changed_id might be set on thread default context, but it is
always cleared on the global context because of usage of g_idle_add. This
can cause the emission of redundant "mounts-change" signals. This should
not cause any issues to the client application, but let's attach the idle
source to the thread-default context instead to avoid those races for sure.
parent 898a9c33
......@@ -1756,6 +1756,9 @@ mtab_file_changed (GFileMonitor *monitor,
GFileMonitorEvent event_type,
gpointer user_data)
{
GMainContext *context;
GSource *source;
if (event_type != G_FILE_MONITOR_EVENT_CHANGED &&
event_type != G_FILE_MONITOR_EVENT_CREATED &&
event_type != G_FILE_MONITOR_EVENT_DELETED)
......@@ -1768,7 +1771,16 @@ mtab_file_changed (GFileMonitor *monitor,
if (mtab_file_changed_id > 0)
return;
mtab_file_changed_id = g_idle_add (mtab_file_changed_cb, NULL);
context = g_main_context_get_thread_default ();
if (!context)
context = g_main_context_default ();
source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_DEFAULT);
g_source_set_callback (source, mtab_file_changed_cb, NULL, NULL);
g_source_set_name (source, "[gio] mtab_file_changed_cb");
g_source_attach (source, context);
g_source_unref (source);
}
static gboolean
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment