diff options
author | Philip Withnall <pwithnall@endlessos.org> | 2021-03-19 22:51:01 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2021-03-20 06:49:09 +0000 |
commit | 7c5fbc921b83321f3e1e56fe24ab1d0840de35ab (patch) | |
tree | 1a7c06438b62256e790b1508412b9964f58e3f05 | |
parent | b2452c2d0023aad6be0751f9785e20f34bed6887 (diff) |
packagekit-glib2: Cancel a transaction if calling Cancel fails
If calling the `Cancel()` D-Bus method on a transaction fails, cancel
the client-side state anyway, to prevent the client from waiting forever
on a response which is unlikely to come.
Spotted in https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1118.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r-- | lib/packagekit-glib2/pk-client.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/packagekit-glib2/pk-client.c b/lib/packagekit-glib2/pk-client.c index 67df1c5ea..eba4ee47d 100644 --- a/lib/packagekit-glib2/pk-client.c +++ b/lib/packagekit-glib2/pk-client.c @@ -569,14 +569,18 @@ pk_client_cancel_cb (GObject *source_object, gpointer user_data) { GDBusProxy *proxy = G_DBUS_PROXY (source_object); + PkClientState *state = user_data; g_autoptr(GError) error = NULL; g_autoptr(GVariant) value = NULL; /* get the result */ value = g_dbus_proxy_call_finish (proxy, res, &error); if (value == NULL) { - /* there's not really a lot we can do here */ - g_warning ("failed to cancel: %s", error->message); + /* Instructing the daemon to cancel failed, so just return an + * error to the client so they don’t wait forever. */ + g_debug ("failed to cancel: %s", error->message); + g_prefix_error (&error, "Failed to cancel: "); + pk_client_state_finish (state, error); return; } } @@ -600,7 +604,7 @@ pk_client_cancellable_cancel_cb (GCancellable *cancellable, PkClientState *state G_DBUS_CALL_FLAGS_NONE, PK_CLIENT_DBUS_METHOD_TIMEOUT, NULL, - pk_client_cancel_cb, NULL); + pk_client_cancel_cb, state); } /* |