aboutsummaryrefslogtreecommitdiff
path: root/src/mm-broadband-modem-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2022-12-15 21:45:53 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2022-12-18 21:52:51 +0000
commita20f2428eea3fa6fd83edeb5f1a844926b4a5b1c (patch)
tree18f161a62516c383e9b3e8cd81ca73ffc3769e20 /src/mm-broadband-modem-qmi.c
parent455c4860915b194c654abb6cd49bcbb483ec650b (diff)
port-qmi: implement the new generic 'removed' signal
Letting the MMBroadbandModemQmi listen for the notifications of the QmiDevice was not a good idea, especially since no explicit reference to the device object was hold in the modem object. This leads to race conditions in which the QmiDevice outlives the MMBroadbandModemQmi and the MMPortQmi, and when the "device-removed" signal is triggered, the program crashes. The MMPortQmi will now emit its own 'removed' signals when the underlying QmiDevice emits "device-removed', ensuring that the signal handler is properly cleared up during the MMPortQmi disposal.
Diffstat (limited to 'src/mm-broadband-modem-qmi.c')
-rw-r--r--src/mm-broadband-modem-qmi.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 98e53bba..284564d1 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -12873,60 +12873,6 @@ parent_initialization_started (GTask *task)
task);
}
-static void
-qmi_device_removed_cb (QmiDevice *device,
- MMBroadbandModemQmi *self)
-{
- /* Reprobe the modem here so we can get notifications back. */
- mm_obj_msg (self, "connection to qmi-proxy for %s lost, reprobing",
- qmi_device_get_path_display (device));
-
- g_signal_handler_disconnect (device, self->priv->qmi_device_removed_id);
- self->priv->qmi_device_removed_id = 0;
-
- mm_base_modem_set_reprobe (MM_BASE_MODEM (self), TRUE);
- mm_base_modem_set_valid (MM_BASE_MODEM (self), FALSE);
-}
-
-static gboolean
-track_qmi_device_removed (MMBroadbandModemQmi *self,
- MMPortQmi *qmi,
- GError **error)
-{
- QmiDevice *device;
-
- device = mm_port_qmi_peek_device (qmi);
- if (!device) {
- g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
- "Cannot track QMI device removal: QMI port no longer available");
- return FALSE;
- }
-
- self->priv->qmi_device_removed_id = g_signal_connect (
- device,
- QMI_DEVICE_SIGNAL_REMOVED,
- G_CALLBACK (qmi_device_removed_cb),
- self);
- return TRUE;
-}
-
-static void
-untrack_qmi_device_removed (MMBroadbandModemQmi *self,
- MMPortQmi *qmi)
-{
- QmiDevice *device;
-
- if (self->priv->qmi_device_removed_id == 0)
- return;
-
- device = mm_port_qmi_peek_device (qmi);
- if (!device)
- return;
-
- g_signal_handler_disconnect (device, self->priv->qmi_device_removed_id);
- self->priv->qmi_device_removed_id = 0;
-}
-
static void allocate_next_client (GTask *task);
static void
@@ -12956,20 +12902,10 @@ static void
allocate_next_client (GTask *task)
{
InitializationStartedContext *ctx;
- MMBroadbandModemQmi *self;
- self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
if (ctx->service_index == G_N_ELEMENTS (qmi_services)) {
- GError *error = NULL;
-
- /* Done we are, track device removal and launch next step */
- if (!track_qmi_device_removed (self, ctx->qmi, &error)) {
- g_task_return_error (task, error);
- g_object_unref (task);
- return;
- }
parent_initialization_started (task);
return;
}
@@ -13086,7 +13022,6 @@ initialization_started (MMBroadbandModem *self,
{
InitializationStartedContext *ctx;
GTask *task;
- GError *error = NULL;
ctx = g_new0 (InitializationStartedContext, 1);
ctx->qmi = mm_broadband_modem_qmi_get_port_qmi (MM_BROADBAND_MODEM_QMI (self));
@@ -13105,14 +13040,6 @@ initialization_started (MMBroadbandModem *self,
}
if (mm_port_qmi_is_open (ctx->qmi)) {
- /* Nothing to be done, just track device removal and launch parent's
- * callback */
- if (!track_qmi_device_removed (MM_BROADBAND_MODEM_QMI (self), ctx->qmi, &error)) {
- g_task_return_error (task, error);
- g_object_unref (task);
- return;
- }
-
parent_initialization_started (task);
return;
}
@@ -13183,8 +13110,6 @@ dispose (GObject *object)
* that will remove all port references right away */
qmi = mm_broadband_modem_qmi_peek_port_qmi (self);
if (qmi) {
- /* Disconnect signal handler for qmi-proxy disappearing, if it exists */
- untrack_qmi_device_removed (self, qmi);
/* If we did open the QMI port during initialization, close it now */
if (mm_port_qmi_is_open (qmi))
mm_port_qmi_close (qmi, NULL, NULL);