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

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@gmail.com>
This commit is contained in:
Greg Suarez
2014-10-23 13:15:17 -07:00
committed by Aleksander Morgado
parent 046d9141c4
commit 3a76c0df57

View File

@@ -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,