aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-08-25 13:12:01 +0200
committerDan Williams <dcbw@redhat.com>2017-09-12 10:22:04 -0500
commit0c7f3380ae96698e496abce1e55c52d21449d57a (patch)
tree6774427a75009a5789cca617f5e710d2aeec7841 /src
parentabfd8d3b08a3a8a98e961969c5e2cb9acd582656 (diff)
bearer-mbim: ensure session is disconnected before trying to connect
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
Diffstat (limited to 'src')
-rw-r--r--src/mm-bearer-mbim.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c
index 6d7aea6d..86e08d4c 100644
--- a/src/mm-bearer-mbim.c
+++ b/src/mm-bearer-mbim.c
@@ -211,6 +211,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
@@ -624,6 +625,26 @@ connect_set_ready (MbimDevice *device,
}
static void
+ensure_disconnected_ready (MbimDevice *device,
+ GAsyncResult *res,
+ GTask *task)
+{
+ ConnectContext *ctx;
+ MbimMessage *response;
+
+ ctx = g_task_get_task_data (task);
+
+ /* 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 (task);
+}
+
+static void
provisioned_contexts_query_ready (MbimDevice *device,
GAsyncResult *res,
GTask *task)
@@ -808,6 +829,37 @@ connect_context_step (GTask *task)
mbim_message_unref (message);
return;
+ case CONNECT_STEP_ENSURE_DISCONNECTED: {
+ MbimMessage *message;
+ GError *error = NULL;
+
+ message = (mbim_message_connect_set_new (
+ 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_task_return_error (task, error);
+ g_object_unref (task);
+ return;
+ }
+
+ mbim_device_command (ctx->device,
+ message,
+ 30,
+ NULL,
+ (GAsyncReadyCallback)ensure_disconnected_ready,
+ task);
+ mbim_message_unref (message);
+ return;
+ }
+
case CONNECT_STEP_CONNECT: {
const gchar *apn;
const gchar *user;