broadband-modem: explicitly abort ongoing attempt when disabling

This commit is contained in:
Aleksander Morgado
2023-05-03 12:38:43 +00:00
committed by Aleksander Morgado
parent 200f827d38
commit d906443eee
3 changed files with 29 additions and 6 deletions
+9
View File
@@ -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)) {
+17 -6
View File
@@ -64,6 +64,21 @@ get_private (MMIfaceModemSimple *self)
return priv;
}
/*****************************************************************************/
/* 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) */
@@ -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,
+3
View File
@@ -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);