diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2023-04-17 16:18:09 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-05-03 12:38:43 +0000 |
commit | d906443eeed6c0ebc555d8b399edf841611e77e1 (patch) | |
tree | 2af49f642c7701e3598bd450881303df56ae6ce7 | |
parent | 200f827d386a15ce096d8dd476b21d09d919d8f0 (diff) | |
download | ModemManager-d906443eeed6c0ebc555d8b399edf841611e77e1.tar.gz |
broadband-modem: explicitly abort ongoing attempt when disabling
-rw-r--r-- | src/mm-broadband-modem.c | 9 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.c | 23 | ||||
-rw-r--r-- | src/mm-iface-modem-simple.h | 3 |
3 files changed, 29 insertions, 6 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 8ae179091..e5a892e4c 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -11235,6 +11235,7 @@ schedule_initial_registration_checks (MMBroadbandModem *self) typedef enum { /* When user requests a disable operation, the process starts here */ DISABLING_STEP_FIRST, + DISABLING_STEP_IFACE_SIMPLE_ABORT_ONGOING, DISABLING_STEP_WAIT_FOR_FINAL_STATE, DISABLING_STEP_DISCONNECT_BEARERS, /* When the disabling is launched due to a failed enable, the process @@ -11423,6 +11424,14 @@ disabling_step (GTask *task) ctx->step++; /* fall through */ + case DISABLING_STEP_IFACE_SIMPLE_ABORT_ONGOING: + /* Connection requests via the Simple interface must be aborted as soon + * as possible, because certain steps may be explicitly waiting for new + * state transitions and such. */ + mm_iface_modem_simple_abort_ongoing (MM_IFACE_MODEM_SIMPLE (ctx->self)); + ctx->step++; + /* fall through */ + case DISABLING_STEP_WAIT_FOR_FINAL_STATE: /* cancellability allowed at this point */ if (g_task_return_error_if_cancelled (task)) { diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c index a3609eaf5..86ed625bc 100644 --- a/src/mm-iface-modem-simple.c +++ b/src/mm-iface-modem-simple.c @@ -65,6 +65,21 @@ get_private (MMIfaceModemSimple *self) } /*****************************************************************************/ +/* Abort ongoing requests, if any */ + +void +mm_iface_modem_simple_abort_ongoing (MMIfaceModemSimple *self) +{ + Private *priv; + + priv = get_private (self); + if (priv->ongoing_connect) { + g_cancellable_cancel (priv->ongoing_connect); + g_clear_object (&priv->ongoing_connect); + } +} + +/*****************************************************************************/ /* Register in either a CDMA or a 3GPP network (or both) */ typedef struct { @@ -1010,7 +1025,6 @@ disconnect_auth_ready (MMBaseModem *self, { g_autoptr(MMBearerList) list = NULL; GError *error = NULL; - Private *priv; if (!mm_base_modem_authorize_finish (self, res, &error)) { g_dbus_method_invocation_take_error (ctx->invocation, error); @@ -1020,11 +1034,8 @@ disconnect_auth_ready (MMBaseModem *self, /* If not disconnecting a specific bearer, also cancel any ongoing * connection attempt. */ - priv = get_private (MM_IFACE_MODEM_SIMPLE (self)); - if (!ctx->bearer_path && priv->ongoing_connect) { - g_cancellable_cancel (priv->ongoing_connect); - g_clear_object (&priv->ongoing_connect); - } + if (!ctx->bearer_path) + mm_iface_modem_simple_abort_ongoing (MM_IFACE_MODEM_SIMPLE (self)); g_object_get (self, MM_IFACE_MODEM_BEARER_LIST, &list, diff --git a/src/mm-iface-modem-simple.h b/src/mm-iface-modem-simple.h index 1aca5de19..673a1ad79 100644 --- a/src/mm-iface-modem-simple.h +++ b/src/mm-iface-modem-simple.h @@ -39,6 +39,9 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMIfaceModemSimple, g_object_unref) /* Initialize Modem Simple interface */ void mm_iface_modem_simple_initialize (MMIfaceModemSimple *self); +/* Abort ongoing operations in Modem Simple interface */ +void mm_iface_modem_simple_abort_ongoing (MMIfaceModemSimple *self); + /* Shutdown Modem Simple interface */ void mm_iface_modem_simple_shutdown (MMIfaceModemSimple *self); |