aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-07-15 18:26:11 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-30 16:17:03 +0200
commitb6909eab7a0531dfe5a3a52b17adcfc57f5ff141 (patch)
tree6ec16ee1d4ba57fa65494bf4d43c544eb4363a9a
parent181cf1e274a0f9f0cacf11d20046ce47b1019e3e (diff)
huawei: limit the number of deferred tasks
The Huawei plugin requires to probe first the USB interface 0; all the other probing tasks in the remaining ports will get deferred until the interface 0 gets probed. But, some modems (e.g. Huawei ET8282), don't expose the USB interface 0 as an AT port, so we get an infinite loop as no port ends up being probed. In order to fix this, we will limit to a predefined maximum the number of times a given probing task is deferred, 4 in this case. So, if a given probing task is deferred for more than 4x3s=12s, probing will get forced.
-rw-r--r--plugins/mm-plugin-huawei.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/plugins/mm-plugin-huawei.c b/plugins/mm-plugin-huawei.c
index 7eebc330..fc1a23f1 100644
--- a/plugins/mm-plugin-huawei.c
+++ b/plugins/mm-plugin-huawei.c
@@ -140,6 +140,9 @@ curc_response_cb (MMPluginBaseSupportsTask *task,
return FALSE;
}
+#define TAG_DEFER_COUNTS_PREFIX "huawei-defer-counts"
+#define MAX_DEFERS 5
+
static MMPluginSupportsResult
supports_port (MMPluginBase *base,
MMModem *existing,
@@ -182,8 +185,31 @@ supports_port (MMPluginBase *base,
* probing other interfaces until we've got if0, at which point we allow
* the other ports to be probed too.
*/
- if (!existing && usbif != 0)
- return MM_PLUGIN_SUPPORTS_PORT_DEFER;
+ if (!existing && usbif != 0) {
+ gchar *tag;
+ guint n_deferred;
+
+ /* We need to defer the probing as usbif 0 wasn't probed yet. We need to
+ * protect against the case of not having usbif 0 as an AT port, and we
+ * do that by limiting the number of times we defer the probing. */
+
+ tag = g_strdup_printf ("%s-%s/%s", TAG_DEFER_COUNTS_PREFIX, subsys, name);
+ /* First time requested will be 0 */
+ n_deferred = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (base), tag));
+ if (n_deferred < MAX_DEFERS) {
+ /* Update defer count */
+ g_object_set_data (G_OBJECT (base), tag, GUINT_TO_POINTER (n_deferred + 1));
+ g_free (tag);
+ return MM_PLUGIN_SUPPORTS_PORT_DEFER;
+ }
+
+ mm_dbg ("(%s): no longer waiting for usbif 0, will launch probing in interface (%s/%s)",
+ mm_plugin_get_name (MM_PLUGIN (base)), subsys, name);
+ g_free (tag);
+
+ /* Clear tag */
+ g_object_set_data (G_OBJECT (base), tag, NULL);
+ }
/* Check if a previous probing was already launched in this port */
if (mm_plugin_base_supports_task_propagate_cached (task)) {