summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-10-24 12:57:09 +0200
committerAleksander Morgado <aleksander@aleksander.es>2016-10-26 14:59:43 +0200
commit06fda6aadc6425ab89c88c9e92249d1c15ddaa3f (patch)
tree3f4bc4600a11042da21acf05dc95477a9acf12b4
parentc16265115f4b4ad26e68a3dfa2db72daccbfa3da (diff)
downloadlibqmi-06fda6aadc6425ab89c88c9e92249d1c15ddaa3f.tar.gz
pdc: 2s of timeout to wait for configs list
There won't be any indication if no configs are available. Based on a patch from Aliaksandr Barouski <alex.borovsky@gmail.com>.
-rw-r--r--src/qmicli/qmicli-pdc.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/qmicli/qmicli-pdc.c b/src/qmicli/qmicli-pdc.c
index d0b8e6b3..ef77e30a 100644
--- a/src/qmicli/qmicli-pdc.c
+++ b/src/qmicli/qmicli-pdc.c
@@ -34,6 +34,7 @@
#include "qmicli.h"
#include "qmicli-helpers.h"
+#define LIST_CONFIGS_TIMEOUT_SECS 2
#define LOAD_CONFIG_CHUNK_SIZE 0x400
/* Info about config */
@@ -60,6 +61,7 @@ typedef struct {
GCancellable *cancellable;
/* local data */
+ guint timeout_id;
GArray *config_list;
guint configs_loaded;
GArray *active_config_id;
@@ -367,6 +369,18 @@ get_config_info_ready_indication (QmiClientPdc *client,
check_list_config_completed ();
}
+static gboolean
+list_configs_timeout (void)
+{
+ /* No indication yet, cancelling */
+ if (!ctx->config_list) {
+ g_printf ("Total configurations: 0\n");
+ operation_shutdown (TRUE);
+ }
+
+ return FALSE;
+}
+
static void
list_configs_ready (QmiClientPdc *client,
GAsyncResult *res)
@@ -402,6 +416,12 @@ list_configs_ready_indication (QmiClientPdc *client,
int i;
guint16 error_code = 0;
+ /* Remove timeout as soon as we get the indication */
+ if (ctx->timeout_id) {
+ g_source_remove (ctx->timeout_id);
+ ctx->timeout_id = 0;
+ }
+
if (!qmi_indication_pdc_list_configs_output_get_indication_result (output, &error_code, &error)) {
g_printerr ("error: couldn't list configs: %s\n", error->message);
g_error_free (error);
@@ -1174,6 +1194,12 @@ qmicli_pdc_run (QmiDevice *device,
return;
}
+ /* We need a timeout, because there will be no indications if no configs
+ * are loaded */
+ ctx->timeout_id = g_timeout_add_seconds (LIST_CONFIGS_TIMEOUT_SECS,
+ (GSourceFunc) list_configs_timeout,
+ NULL);
+
qmi_client_pdc_list_configs (ctx->client,
input,
10,