From f3cdafb746bfa661e7e4ab553bd757eeba7d27c9 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 3 May 2023 14:25:51 +0000 Subject: shared-qmi: don't assume cancellation signal handler is setup in the registration wait The cancellation_id will not be set if the cancellable is already cancelled by the time g_cancellable_connect() is called. --- src/mm-shared-qmi.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c index 236dbcf62..31e372ad7 100644 --- a/src/mm-shared-qmi.c +++ b/src/mm-shared-qmi.c @@ -210,8 +210,8 @@ register_in_network_cancelled (GCancellable *cancellable, ctx = g_task_get_task_data (task); g_assert (ctx->cancellable); - g_assert (ctx->cancellable_id); - ctx->cancellable_id = 0; + if (ctx->cancellable_id) + ctx->cancellable_id = 0; g_assert (ctx->timeout_id); g_source_remove (ctx->timeout_id); @@ -241,9 +241,10 @@ register_in_network_timeout (GTask *task) g_signal_handler_disconnect (ctx->client, ctx->serving_system_indication_id); ctx->serving_system_indication_id = 0; - g_assert (!ctx->cancellable || ctx->cancellable_id); - g_cancellable_disconnect (ctx->cancellable, ctx->cancellable_id); - ctx->cancellable_id = 0; + if (ctx->cancellable && ctx->cancellable_id) { + g_cancellable_disconnect (ctx->cancellable, ctx->cancellable_id); + ctx->cancellable_id = 0; + } /* the 3GPP interface will take care of checking if the registration is * the one we asked for */ @@ -283,9 +284,10 @@ register_in_network_ready (GTask *task, g_source_remove (ctx->timeout_id); ctx->timeout_id = 0; - g_assert (!ctx->cancellable || ctx->cancellable_id); - g_cancellable_disconnect (ctx->cancellable, ctx->cancellable_id); - ctx->cancellable_id = 0; + if (ctx->cancellable && ctx->cancellable_id) { + g_cancellable_disconnect (ctx->cancellable, ctx->cancellable_id); + ctx->cancellable_id = 0; + } /* the 3GPP interface will take care of checking if the registration is * the one we asked for */ -- cgit v1.2.1