cloud-setup: simplify cancellation in _get_config_fetch_cancelled_cb()

If we call g_cancellable_connect() on a GCancellable that is already
cancelled, then the callback is invoked synchronously. We need to
handle that.

However, we can slightly simplify the code. There is no change in
behavior, but we can always let the cancelled callback return the
result.
This commit is contained in:
Thomas Haller 2020-12-04 11:23:28 +01:00
parent 422ab25626
commit be8a3f9902
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -268,9 +268,6 @@ _get_config_fetch_cancelled_cb(GObject *object, gpointer user_data)
{
GetConfigIfaceData *iface_data = user_data;
if (iface_data->cancelled_id == 0)
return;
nm_clear_g_signal_handler(g_task_get_cancellable(iface_data->get_config_data->task),
&iface_data->cancelled_id);
_get_config_task_maybe_return(iface_data, nm_utils_error_new_cancelled(FALSE, NULL));
@ -334,7 +331,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
iface_data,
NULL);
if (cancelled_id == 0) {
_get_config_task_maybe_return(iface_data, nm_utils_error_new_cancelled(FALSE, NULL));
/* the callback was already invoked synchronously and the task already returned. */
return;
}