[PATCH] bearer-mbim: Implement report_connection_status() to set the port as disconnected

Aleksander Morgado aleksander at aleksander.es
Wed Oct 29 14:26:41 PDT 2014


On 23/10/14 22:15, Greg Suarez wrote:
> When the MBIM modem unexpectedly loses connection the port state never
> gets set as disconnected thus when trying to reestablish a new
> connection the bearer cannot find a port in the disconnected state.
> 
> Signed-off-by: Greg Suarez <gpsuarez2512 at gmail.com>
> ---

Pushed to git master and mm-1-4.

Thanks!


>  src/mm-bearer-mbim.c | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
> index 358b261..c554c52 100644
> --- a/src/mm-bearer-mbim.c
> +++ b/src/mm-bearer-mbim.c
> @@ -950,6 +950,15 @@ disconnect_finish (MMBaseBearer *self,
>      return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
>  }
>  
> +static void
> +reset_bearer_connection (MMBearerMbim *self)
> +{
> +    if (self->priv->data) {
> +        mm_port_set_connected (self->priv->data, FALSE);
> +        g_clear_object (&self->priv->data);
> +    }
> +}
> +
>  static void disconnect_context_step (DisconnectContext *ctx);
>  
>  static void
> @@ -1064,8 +1073,7 @@ disconnect_context_step (DisconnectContext *ctx)
>  
>      case DISCONNECT_STEP_LAST:
>          /* Port is disconnected; update the state */
> -        mm_port_set_connected (ctx->self->priv->data, FALSE);
> -        g_clear_object (&ctx->self->priv->data);
> +        reset_bearer_connection (ctx->self);
>  
>          g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
>          disconnect_context_complete_and_free (ctx);
> @@ -1126,6 +1134,20 @@ mm_bearer_mbim_get_session_id (MMBearerMbim *self)
>  
>  /*****************************************************************************/
>  
> +static void
> +report_connection_status (MMBaseBearer *self,
> +                          MMBearerConnectionStatus status)
> +{
> +    if (status == MM_BEARER_CONNECTION_STATUS_DISCONNECTED)
> +        /* Cleanup all connection related data */
> +        reset_bearer_connection (MM_BEARER_MBIM (self));
> +
> +    /* Chain up parent's report_connection_status() */
> +    MM_BASE_BEARER_CLASS (mm_bearer_mbim_parent_class)->report_connection_status (self, status);
> +}
> +
> +/*****************************************************************************/
> +
>  MMBaseBearer *
>  mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
>                      MMBearerProperties *config,
> @@ -1221,6 +1243,7 @@ mm_bearer_mbim_class_init (MMBearerMbimClass *klass)
>      base_bearer_class->connect_finish = connect_finish;
>      base_bearer_class->disconnect = disconnect;
>      base_bearer_class->disconnect_finish = disconnect_finish;
> +    base_bearer_class->report_connection_status = report_connection_status;
>  
>      properties[PROP_SESSION_ID] =
>          g_param_spec_uint (MM_BEARER_MBIM_SESSION_ID,
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list