From 3a76c0df5790dc4cd2019bd67b1e36c7f4114b32 Mon Sep 17 00:00:00 2001 From: Greg Suarez Date: Thu, 23 Oct 2014 13:15:17 -0700 Subject: 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 --- src/mm-bearer-mbim.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 358b261a..c554c527 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, -- cgit v1.2.3-70-g09d2