diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2023-04-14 12:03:32 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-05-03 12:38:43 +0000 |
commit | acc98e43ba3aeea8d8be1a92d009f775a8cd83f4 (patch) | |
tree | 192d8065fc80ec4979df825d0a2b3475b65ce91d /src/mm-iface-modem-simple.c | |
parent | b9a7cad2470bba1cf06a05577a248cc37a1f3bc4 (diff) |
iface-modem-3gpp: allow cancelling the wait for packet service state
When a request to disable the modem arrives while the packet service
state wait is ongoing we were not correctly cancelling the operation.
The main reason for this is that this operation does not change the
modem state, and so the "wait for final state" logic in the disabling
sequence was not being considered.
We solve this by plugging in the Simple.Connect() operation
cancellable in the wait for packet service state operation. The
connection attempt will be cancelled during the disabling sequence as
well, and when that happens we will explicitly halt the packet service
state wait as well.
Diffstat (limited to 'src/mm-iface-modem-simple.c')
-rw-r--r-- | src/mm-iface-modem-simple.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c index 245ae660..635d915d 100644 --- a/src/mm-iface-modem-simple.c +++ b/src/mm-iface-modem-simple.c @@ -228,7 +228,7 @@ typedef struct { static void packet_service_attach_in_3gpp_network_context_free (PacketServiceAttachIn3gppNetworkContext *ctx) { - g_assert (!ctx->error); + g_clear_error (&ctx->error); g_slice_free (PacketServiceAttachIn3gppNetworkContext, ctx); } @@ -296,6 +296,11 @@ packet_service_attach_in_3gpp_network_step (GTask *task) self = g_task_get_source_object (task); ctx = g_task_get_task_data (task); + if (g_task_return_error_if_cancelled (task)) { + g_object_unref (task); + return; + } + switch (ctx->step) { case PACKET_SERVICE_ATTACH_IN_3GPP_NETWORK_STEP_FIRST: ctx->step++; @@ -305,6 +310,7 @@ packet_service_attach_in_3gpp_network_step (GTask *task) g_assert (!ctx->error); mm_iface_modem_3gpp_wait_for_packet_service_state (MM_IFACE_MODEM_3GPP (self), MM_MODEM_3GPP_PACKET_SERVICE_STATE_ATTACHED, + g_task_get_cancellable (task), (GAsyncReadyCallback)wait_for_packet_service_state_ready, task); return; @@ -322,6 +328,7 @@ packet_service_attach_in_3gpp_network_step (GTask *task) g_assert (!ctx->error); mm_iface_modem_3gpp_wait_for_packet_service_state (MM_IFACE_MODEM_3GPP (self), MM_MODEM_3GPP_PACKET_SERVICE_STATE_ATTACHED, + g_task_get_cancellable (task), (GAsyncReadyCallback)wait_for_packet_service_state_ready, task); return; @@ -341,13 +348,14 @@ packet_service_attach_in_3gpp_network_step (GTask *task) static void packet_service_attach_in_3gpp_network (MMIfaceModemSimple *self, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { PacketServiceAttachIn3gppNetworkContext *ctx; GTask *task; - task = g_task_new (self, NULL, callback, user_data); + task = g_task_new (self, cancellable, callback, user_data); ctx = g_slice_new0 (PacketServiceAttachIn3gppNetworkContext); ctx->step = PACKET_SERVICE_ATTACH_IN_3GPP_NETWORK_STEP_FIRST; g_task_set_task_data (task, ctx, (GDestroyNotify)packet_service_attach_in_3gpp_network_context_free); @@ -777,6 +785,7 @@ connection_step (ConnectionContext *ctx) if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (ctx->self))) { packet_service_attach_in_3gpp_network ( ctx->self, + ctx->cancellable, (GAsyncReadyCallback)packet_service_attach_in_3gpp_network_ready, ctx); return; |