diff options
author | Loic Poulain <loic.poulain@linaro.org> | 2020-12-04 10:45:45 +0100 |
---|---|---|
committer | Loic Poulain <loic.poulain@linaro.org> | 2020-12-04 10:45:45 +0100 |
commit | 4f46583bb5e6d0bb081181c0a6290999523e58b6 (patch) | |
tree | 127e1549c03bf23e9bf523f8af5f7d539801dd00 | |
parent | ca78102f5427835aa72dbfeb3016c672c7024382 (diff) |
Fix client release
Ensure that CID are properly released to avoid further CID alloc issues.
Ensure all client releases have complete before exiting.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
-rwxr-xr-x | mhi-qmi-connect | bin | 100568 -> 103616 bytes | |||
-rw-r--r-- | mhi-qmi-connect.c | 39 |
2 files changed, 24 insertions, 15 deletions
diff --git a/mhi-qmi-connect b/mhi-qmi-connect Binary files differindex 14f99a2..463e828 100755 --- a/mhi-qmi-connect +++ b/mhi-qmi-connect diff --git a/mhi-qmi-connect.c b/mhi-qmi-connect.c index 838fe6e..949acee 100644 --- a/mhi-qmi-connect.c +++ b/mhi-qmi-connect.c @@ -74,6 +74,7 @@ static gboolean wda_allocated = FALSE; static gboolean ping; static int exit_reason; +static int remaining_clients; static void op_shutdown(int reason); @@ -88,25 +89,39 @@ enum { static void release_client_ready(QmiDevice *dev, GAsyncResult *res) { + if (--remaining_clients <= 0) + g_idle_add((GSourceFunc)g_main_loop_quit, loop); + return; } static void release_qmi_clients(void) { + QmiDeviceReleaseClientFlags flags = QMI_DEVICE_RELEASE_CLIENT_FLAGS_RELEASE_CID; connection_status = QMI_WDS_CONNECTION_STATUS_UNKNOWN; - if (QMI_IS_CLIENT(client_wda)) - qmi_device_release_client(device, (QmiClient *)client_wda, 0, 5, cancellable, + remaining_clients = 0; + if (QMI_IS_CLIENT(client_wda)) { + qmi_device_release_client(device, (QmiClient *)client_wda, flags, 5, cancellable, (GAsyncReadyCallback) release_client_ready, NULL); - if (QMI_IS_CLIENT(client_uim)) - qmi_device_release_client(device, (QmiClient *)client_uim, 0, 5, cancellable, + remaining_clients++; + } if (QMI_IS_CLIENT(client_uim)) { + qmi_device_release_client(device, (QmiClient *)client_uim, flags, 5, cancellable, (GAsyncReadyCallback) release_client_ready, NULL); - if (QMI_IS_CLIENT(client_dms)) - qmi_device_release_client(device, (QmiClient *)client_dms, 0, 5, cancellable, + remaining_clients++; + } if (QMI_IS_CLIENT(client_dms)) { + qmi_device_release_client(device, (QmiClient *)client_dms, flags, 5, cancellable, (GAsyncReadyCallback) release_client_ready, NULL); - if (QMI_IS_CLIENT(client_wds)) - qmi_device_release_client(device, (QmiClient *)client_wds, 0, 5, cancellable, + remaining_clients++; + } + if (QMI_IS_CLIENT(client_wds)) { + qmi_device_release_client(device, (QmiClient *)client_wds, flags, 5, cancellable, (GAsyncReadyCallback) release_client_ready, NULL); + remaining_clients++; + } + + if (remaining_clients == 0) + g_idle_add((GSourceFunc)g_main_loop_quit, loop); } static void stop_rmnet(void) @@ -631,7 +646,7 @@ static void allocate_wda_client_ready(QmiDevice *dev, GAsyncResult *res) op_shutdown(SHUTDOWN_ERROR); return; } - + input = qmi_message_wda_set_data_format_input_new(); /* QMAP aggregation protocol */ @@ -951,12 +966,6 @@ static void op_shutdown(int reason) stop_rmnet(); stop_network(); release_qmi_clients(); - - if (loop && g_main_loop_is_running(loop)) { - g_printerr("cancelling the main loop...\n"); - g_idle_add((GSourceFunc)g_main_loop_quit, loop); - } - exit_reason = reason; } |