summaryrefslogtreecommitdiff
path: root/src/libqmi-glib/qmi-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libqmi-glib/qmi-device.c')
-rw-r--r--src/libqmi-glib/qmi-device.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/libqmi-glib/qmi-device.c b/src/libqmi-glib/qmi-device.c
index 3c149154..b23f172b 100644
--- a/src/libqmi-glib/qmi-device.c
+++ b/src/libqmi-glib/qmi-device.c
@@ -84,6 +84,7 @@ enum {
PROP_NO_FILE_CHECK,
PROP_PROXY_PATH,
PROP_WWAN_IFACE,
+ PROP_CONSECUTIVE_TIMEOUTS,
#if QMI_QRTR_SUPPORTED
PROP_NODE,
#endif
@@ -134,6 +135,9 @@ struct _QmiDevicePrivate {
/* HT of clients that want to get indications */
GHashTable *registered_clients;
+
+ /* Number of consecutive timeouts detected */
+ guint consecutive_timeouts;
};
#if QMI_QRTR_SUPPORTED
@@ -411,6 +415,13 @@ transaction_timed_out (TransactionWaitContext *ctx)
tr->timeout_source = NULL;
+ /* Increase number of consecutive timeouts */
+ ctx->self->priv->consecutive_timeouts++;
+ g_object_notify_by_pspec (G_OBJECT (ctx->self), properties[PROP_CONSECUTIVE_TIMEOUTS]);
+ g_debug ("[%s] Number of consecutive timeouts: %u",
+ qmi_file_get_path_display (ctx->self->priv->file),
+ ctx->self->priv->consecutive_timeouts);
+
error = g_error_new (QMI_CORE_ERROR, QMI_CORE_ERROR_TIMEOUT, "Transaction timed out");
transaction_abort (ctx->self, tr, error);
@@ -530,6 +541,16 @@ device_hangup_transactions (QmiDevice *self)
}
/*****************************************************************************/
+
+guint
+qmi_device_get_consecutive_timeouts (QmiDevice *self)
+{
+ g_return_val_if_fail (QMI_IS_DEVICE (self), 0);
+
+ return self->priv->consecutive_timeouts;
+}
+
+/*****************************************************************************/
/* Version info request */
GArray *
@@ -1762,6 +1783,14 @@ process_message (QmiMessage *message,
return;
}
+ /* Reset number of consecutive timeouts */
+ if (self->priv->consecutive_timeouts > 0) {
+ g_debug ("[%s] Reseted number of consecutive timeouts",
+ qmi_file_get_path_display (self->priv->file));
+ self->priv->consecutive_timeouts = 0;
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CONSECUTIVE_TIMEOUTS]);
+ }
+
/* Matched transactions translated with the same context as the request */
trace_message (self, message, FALSE, "response", tr->message_context);
/* Report the reply message */
@@ -3168,6 +3197,9 @@ set_property (GObject *object,
g_free (self->priv->proxy_path);
self->priv->proxy_path = g_value_dup_string (value);
break;
+ case PROP_CONSECUTIVE_TIMEOUTS:
+ g_assert_not_reached ();
+ break;
#if QMI_QRTR_SUPPORTED
case PROP_NODE:
g_assert (!self->priv->node);
@@ -3201,6 +3233,9 @@ get_property (GObject *object,
reload_wwan_iface_name (self);
g_value_set_string (value, self->priv->wwan_iface);
break;
+ case PROP_CONSECUTIVE_TIMEOUTS:
+ g_value_set_uint (value, self->priv->consecutive_timeouts);
+ break;
#if QMI_QRTR_SUPPORTED
case PROP_NODE:
g_value_set_object (value, self->priv->node);
@@ -3382,6 +3417,20 @@ qmi_device_class_init (QmiDeviceClass *klass)
G_PARAM_READABLE);
g_object_class_install_property (object_class, PROP_WWAN_IFACE, properties[PROP_WWAN_IFACE]);
+
+ /**
+ * QmiDevice:device-consecutive-timeouts:
+ *
+ * Since: 1.32
+ */
+ properties[PROP_CONSECUTIVE_TIMEOUTS] =
+ g_param_spec_uint (QMI_DEVICE_CONSECUTIVE_TIMEOUTS,
+ "Consecutive timeouts",
+ "Number of consecutive timeouts detected in requests sent to the device",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READABLE);
+ g_object_class_install_property (object_class, PROP_CONSECUTIVE_TIMEOUTS, properties[PROP_CONSECUTIVE_TIMEOUTS]);
+
/**
* QmiDevice:device-node:
*