summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2020-09-08 15:33:28 +0000
committerOndrej Holy <oholy@redhat.com>2020-12-14 07:38:26 +0000
commit397ef292e7c97bb9e4ce13acdd0b4af3efa36cdc (patch)
treef9aefdd59a922d3523cb631d36c9dd5abbccb644
parentddd896548c2872abea96f4afcd995d3badd8f87e (diff)
downloadgvfs-397ef292e7c97bb9e4ce13acdd0b4af3efa36cdc.tar.gz
trash: Explicitly cancel file monitor to prevent deadlock
It seems that if file monitor is not canceled before unreffing, it can cause deadlock. Let's explicitly cancel it before unreffing to prevent this. See https://gitlab.gnome.org/GNOME/glib/-/issues/1941. Fixes: https://gitlab.gnome.org/GNOME/gvfs/-/issues/485 (cherry picked from commit dc21a0948bcbe8a6d79d674bd1e4d63ded57d340)
-rw-r--r--daemon/trashlib/dirwatch.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/daemon/trashlib/dirwatch.c b/daemon/trashlib/dirwatch.c
index f2bc6924..6a2f1f6f 100644
--- a/daemon/trashlib/dirwatch.c
+++ b/daemon/trashlib/dirwatch.c
@@ -216,6 +216,7 @@ dir_watch_recursive_destroy (gpointer user_data)
watch->state = FALSE;
}
+ g_file_monitor_cancel (watch->parent_monitor);
g_object_unref (watch->parent_monitor);
watch->parent_monitor = NULL;
}
@@ -271,7 +272,10 @@ dir_watch_free (DirWatch *watch)
if (watch != NULL)
{
if (watch->parent_monitor)
- g_object_unref (watch->parent_monitor);
+ {
+ g_file_monitor_cancel (watch->parent_monitor);
+ g_object_unref (watch->parent_monitor);
+ }
g_object_unref (watch->directory);
g_object_unref (watch->topdir);