aboutsummaryrefslogtreecommitdiff
path: root/src/mm-shared-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2023-05-03 14:21:31 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2023-05-03 14:21:31 +0000
commit28eec45dbb8fca7e51165b29cd6a36c7ef78abb4 (patch)
tree8c8590bc8644595a4e1cdd579b2944d66d6b12bc /src/mm-shared-qmi.c
parent5bd8bbb40857b6949a5c76d13387e9d6373cbf1f (diff)
shared-qmi: ensure cancellation is setup last in the registration wait
register_in_network_cancelled() may be called early if the given cancellable is already cancelled, and if so, we want it to remove the timeout and signal handler, which should have been configured before setting up the cancellation signal handler.
Diffstat (limited to 'src/mm-shared-qmi.c')
-rw-r--r--src/mm-shared-qmi.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mm-shared-qmi.c b/src/mm-shared-qmi.c
index 8dc6e010..236dbcf6 100644
--- a/src/mm-shared-qmi.c
+++ b/src/mm-shared-qmi.c
@@ -330,12 +330,6 @@ initiate_network_register_ready (QmiClientNas *client,
* will cancel the others.
*/
- if (ctx->cancellable)
- ctx->cancellable_id = g_cancellable_connect (ctx->cancellable,
- G_CALLBACK (register_in_network_cancelled),
- task,
- NULL);
-
ctx->serving_system_indication_id = g_signal_connect_swapped (client,
"serving-system",
G_CALLBACK (register_in_network_ready),
@@ -345,6 +339,15 @@ initiate_network_register_ready (QmiClientNas *client,
(GSourceFunc) register_in_network_timeout,
task);
+ /* The cancellable may already be cancelled, and if so the given callback will be called
+ * right away. So make sure this cancellable is always configured last, so that it clears the
+ * timeout or signal handler upon early cancellation. */
+ if (ctx->cancellable)
+ ctx->cancellable_id = g_cancellable_connect (ctx->cancellable,
+ G_CALLBACK (register_in_network_cancelled),
+ task,
+ NULL);
+
out:
if (output)