diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2023-12-01 09:58:19 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2023-12-01 10:14:45 +0000 |
commit | 5fb285664534c1d65fdb446ea20a4900f08dbdef (patch) | |
tree | 8d05b64bfd8fa33eef21bf34ddc0952828fdec86 /src/mm-broadband-modem-mbim.c | |
parent | dc4b1ec0f3d81adce37ea2918b7c651a5a783597 (diff) |
iface-modem: allow cancellability during unlock required checks
The process doing the unlock required checks may need a lot of retries
e.g. to decide whether a SIM card is available or not. If we do a
quick SIM eject, so the unlock required check starts looping, and then
insert the SIM again, we expect the loop to be cancelled right away,
so that the new modem object can be reprobed without any interference
from the old modem object.
We now take the modem-wide cancellable and bind it to the GTask in
mm_iface_modem_update_lock_info(), and we pass it down to every
sub-step of the async logic in the operation. We also plug the
cancellable to the delayed retries in the interface logic, to allow
aborting the checks right away
Diffstat (limited to 'src/mm-broadband-modem-mbim.c')
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index b46dce72..2bf032f8 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -1518,12 +1518,12 @@ load_unlock_required_context_free (LoadUnlockRequiredContext *ctx) } static MMModemLock -modem_load_unlock_required_finish (MMIfaceModem *self, - GAsyncResult *res, - GError **error) +modem_load_unlock_required_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) { GError *inner_error = NULL; - gssize value; + gssize value; value = g_task_propagate_int (G_TASK (res), &inner_error); if (inner_error) { @@ -1534,9 +1534,9 @@ modem_load_unlock_required_finish (MMIfaceModem *self, } static void -pin_query_ready (MbimDevice *device, +pin_query_ready (MbimDevice *device, GAsyncResult *res, - GTask *task) + GTask *task) { MbimMessage *response; GError *error = NULL; @@ -1575,8 +1575,6 @@ pin_query_ready (MbimDevice *device, mbim_message_unref (response); } -static gboolean wait_for_sim_ready (GTask *task); - static void unlock_required_subscriber_ready_state_ready (MbimDevice *device, GAsyncResult *res, @@ -1714,7 +1712,7 @@ unlock_required_subscriber_ready_state_ready (MbimDevice *device, mbim_device_command (device, message, 10, - NULL, + g_task_get_cancellable (task), (GAsyncReadyCallback)pin_query_ready, task); mbim_message_unref (message); @@ -1740,7 +1738,7 @@ wait_for_sim_ready (GTask *task) mbim_device_command (ctx->device, message, 10, - NULL, + g_task_get_cancellable (task), (GAsyncReadyCallback)unlock_required_subscriber_ready_state_ready, task); mbim_message_unref (message); @@ -1748,14 +1746,15 @@ wait_for_sim_ready (GTask *task) } static void -modem_load_unlock_required (MMIfaceModem *self, - gboolean last_attempt, - GAsyncReadyCallback callback, - gpointer user_data) +modem_load_unlock_required (MMIfaceModem *self, + gboolean last_attempt, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { LoadUnlockRequiredContext *ctx; - MbimDevice *device; - GTask *task; + MbimDevice *device; + GTask *task; if (!peek_device (self, &device, callback, user_data)) return; @@ -1764,7 +1763,7 @@ modem_load_unlock_required (MMIfaceModem *self, ctx->device = g_object_ref (device); ctx->last_attempt = last_attempt; - task = g_task_new (self, NULL, callback, user_data); + task = g_task_new (self, cancellable, callback, user_data); g_task_set_task_data (task, ctx, (GDestroyNotify)load_unlock_required_context_free); wait_for_sim_ready (task); |