[PATCH 1.6] bearer-mbim: ensure session is disconnected before trying to connect

Aleksander Morgado aleksander at aleksander.es
Wed Sep 13 09:38:48 UTC 2017


On Tue, Sep 12, 2017 at 6:46 PM, Aleksander Morgado
<aleksander at aleksander.es> wrote:
> Hey!
>
>
> On Sep 12, 2017 17:31, "Dan Williams" <dcbw at redhat.com> wrote:
>
> If a suspend/resume cycle happens or ModemManager is restarted (e.g.
> after a crash) the modem may be left with a given session id
> connected. With this change we're forcing a session disconnection
> before we attempt a session connection.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=102231
> (cherry picked from commit 0c7f3380ae96698e496abce1e55c52d21449d57a)
>
>
> Good for mm-1-6
>

Pushed it to mm-1-6 already.

>
> ---
>  src/mm-bearer-mbim.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
>
> diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
> index 5be16d8..4bf3f1d 100644
> --- a/src/mm-bearer-mbim.c
> +++ b/src/mm-bearer-mbim.c
> @@ -221,6 +221,7 @@ typedef enum {
>      CONNECT_STEP_FIRST,
>      CONNECT_STEP_PACKET_SERVICE,
>      CONNECT_STEP_PROVISIONED_CONTEXTS,
> +    CONNECT_STEP_ENSURE_DISCONNECTED,
>      CONNECT_STEP_CONNECT,
>      CONNECT_STEP_IP_CONFIGURATION,
>      CONNECT_STEP_LAST
> @@ -638,6 +639,23 @@ connect_set_ready (MbimDevice *device,
>  }
>
>  static void
> +ensure_disconnected_ready (MbimDevice     *device,
> +                           GAsyncResult   *res,
> +                           ConnectContext *ctx)
> +{
> +    MbimMessage *response;
> +
> +    /* Ignore all errors, just go on */
> +    response = mbim_device_command_finish (device, res, NULL);
> +    if (response)
> +        mbim_message_unref (response);
> +
> +    /* Keep on */
> +    ctx->step++;
> +    connect_context_step (ctx);
> +}
> +
> +static void
>  provisioned_contexts_query_ready (MbimDevice *device,
>                                    GAsyncResult *res,
>                                    ConnectContext *ctx)
> @@ -815,6 +833,37 @@ connect_context_step (ConnectContext *ctx)
>          mbim_message_unref (message);
>          return;
>
> +    case CONNECT_STEP_ENSURE_DISCONNECTED: {
> +        MbimMessage *message;
> +        GError *error = NULL;
> +
> +        message = (mbim_message_connect_set_new (
> +                       ctx->self->priv->session_id,
> +                       MBIM_ACTIVATION_COMMAND_DEACTIVATE,
> +                       "",
> +                       "",
> +                       "",
> +                       MBIM_COMPRESSION_NONE,
> +                       MBIM_AUTH_PROTOCOL_NONE,
> +                       MBIM_CONTEXT_IP_TYPE_DEFAULT,
> +                       mbim_uuid_from_context_type
> (MBIM_CONTEXT_TYPE_INTERNET),
> +                       &error));
> +        if (!message) {
> +            g_simple_async_result_take_error (ctx->result, error);
> +            connect_context_complete_and_free (ctx);
> +            return;
> +        }
> +
> +        mbim_device_command (ctx->device,
> +                             message,
> +                             30,
> +                             NULL,
> +
> (GAsyncReadyCallback)ensure_disconnected_ready,
> +                             ctx);
> +        mbim_message_unref (message);
> +        return;
> +    }
> +
>      case CONNECT_STEP_CONNECT: {
>          const gchar *apn;
>          const gchar *user;
> --
> 2.9.5
>
>



-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list