summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2016-05-11 13:18:12 -0500
committerDan Williams <dcbw@redhat.com>2016-05-11 13:18:12 -0500
commit732502869802b4a719e06aaf524b9a043530329f (patch)
tree53634ff23bde3dc6a3eb1627594fe9c645b09d5f
parentf60732fa98e32941e1c29cea4b9d2259fb277ce1 (diff)
downloadModemManager-dcbw/mbm-connect-disconnect-cleanup.tar.gz
broadband-bearer-mbm: connect errors should trigger a disconnectdcbw/mbm-connect-disconnect-cleanup
Otherwise we may leave a bearer connected when ModemManager doesn't think it's connected. Prevents a CME ERROR 277 loop on connect when the bearer hasn't been torn down correctly.
-rw-r--r--plugins/mbm/mm-broadband-bearer-mbm.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/plugins/mbm/mm-broadband-bearer-mbm.c b/plugins/mbm/mm-broadband-bearer-mbm.c
index 3e868f427..196604644 100644
--- a/plugins/mbm/mm-broadband-bearer-mbm.c
+++ b/plugins/mbm/mm-broadband-bearer-mbm.c
@@ -139,6 +139,36 @@ dial_3gpp_report_connection_status (gpointer data,
ctx->e2nap_status = status;
}
+static void
+connect_error_disconnect_ready (MMBroadbandBearer *self,
+ GAsyncResult *res,
+ Dial3gppContext *ctx)
+{
+ MM_BROADBAND_BEARER_GET_CLASS (self)->disconnect_3gpp_finish (
+ self,
+ res,
+ NULL);
+ dial_3gpp_context_complete_and_free (ctx);
+}
+
+static void
+connect_error_disconnect_start (Dial3gppContext *ctx)
+{
+ /* We don't care about connect status anymore */
+ if (ctx->self->priv->connect_pending == ctx)
+ ctx->self->priv->connect_pending = NULL;
+
+ MM_BROADBAND_BEARER_GET_CLASS (ctx->self)->disconnect_3gpp (
+ MM_BROADBAND_BEARER (ctx->self),
+ MM_BROADBAND_MODEM (ctx->modem),
+ ctx->primary,
+ NULL,
+ ctx->data,
+ ctx->cid,
+ (GAsyncReadyCallback) connect_error_disconnect_ready,
+ ctx);
+}
+
static gboolean
handle_e2nap_connect_status (Dial3gppContext *ctx)
{
@@ -181,7 +211,7 @@ connect_poll_ready (MMBaseModem *modem,
response = mm_base_modem_at_command_full_finish (modem, res, &error);
if (!response) {
g_simple_async_result_take_error (ctx->result, error);
- dial_3gpp_context_complete_and_free (ctx);
+ connect_error_disconnect_start (ctx);
return;
}
@@ -217,7 +247,7 @@ connect_poll_cb (Dial3gppContext *ctx)
MM_CORE_ERROR,
MM_CORE_ERROR_CANCELLED,
"Dial operation has been cancelled");
- dial_3gpp_context_complete_and_free (ctx);
+ connect_error_disconnect_start (ctx);
return G_SOURCE_REMOVE;
}
@@ -231,7 +261,7 @@ connect_poll_cb (Dial3gppContext *ctx)
MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_NETWORK_TIMEOUT,
"Connection attempt timed out");
- dial_3gpp_context_complete_and_free (ctx);
+ connect_error_disconnect_start (ctx);
return G_SOURCE_REMOVE;
}
@@ -260,7 +290,7 @@ activate_ready (MMBaseModem *modem,
if (!mm_base_modem_at_command_full_finish (modem, res, &error)) {
g_simple_async_result_take_error (ctx->result, error);
- dial_3gpp_context_complete_and_free (ctx);
+ connect_error_disconnect_start (ctx);
return;
}