Merge branch 'mcatanzaro/cancellable-deadlock' into 'master'

file-backend: avoid deadlock when portal op is canceled

Closes #86

See merge request GNOME/libsecret!118
This commit is contained in:
Dhanuka Warusadura 2023-04-27 15:44:24 +00:00
commit e5ec8c4e24

View File

@ -206,6 +206,7 @@ typedef struct {
GDBusConnection *connection; GDBusConnection *connection;
gchar *request_path; gchar *request_path;
guint portal_signal_id; guint portal_signal_id;
GCancellable *cancellable;
gulong cancellable_signal_id; gulong cancellable_signal_id;
} InitClosure; } InitClosure;
@ -218,6 +219,14 @@ init_closure_free (gpointer data)
g_clear_pointer (&init->buffer, egg_secure_free); g_clear_pointer (&init->buffer, egg_secure_free);
g_clear_object (&init->connection); g_clear_object (&init->connection);
g_clear_pointer (&init->request_path, g_free); g_clear_pointer (&init->request_path, g_free);
if (init->cancellable_signal_id) {
g_cancellable_disconnect (init->cancellable, init->cancellable_signal_id);
init->cancellable_signal_id = 0;
}
/* Note: do not cancel the cancellable here! That's for the API user to
* do. We're just keeping track of it here so we can disconnect.
*/
g_clear_object (&init->cancellable);
g_free (init); g_free (init);
} }
@ -352,9 +361,6 @@ on_portal_cancel (GCancellable *cancellable,
cancellable, cancellable,
on_portal_request_close, on_portal_request_close,
task); task);
g_cancellable_disconnect (cancellable, init->cancellable_signal_id);
init->cancellable_signal_id = 0;
} }
static void static void
@ -575,6 +581,7 @@ secret_file_backend_real_init_async (GAsyncInitable *initable,
init = g_new0 (InitClosure, 1); init = g_new0 (InitClosure, 1);
init->io_priority = io_priority; init->io_priority = io_priority;
init->file = file; init->file = file;
init->cancellable = g_object_ref (cancellable);
g_task_set_task_data (task, init, init_closure_free); g_task_set_task_data (task, init, init_closure_free);
g_bus_get (G_BUS_TYPE_SESSION, cancellable, on_bus_get, task); g_bus_get (G_BUS_TYPE_SESSION, cancellable, on_bus_get, task);
} else { } else {