summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-01-17 18:32:42 +0100
committerAleksander Morgado <aleksander@aleksander.es>2015-01-17 18:41:33 +0100
commit7ab8135fb2970db32bfd0cfcc170f690e1409a2a (patch)
tree9020756bc3c775c80d05c586278d5d745fcf65b6
parent8a8104a9b5952a451b6346b6a188815f3ea0a508 (diff)
downloadlibmbim-7ab8135fb2970db32bfd0cfcc170f690e1409a2a.tar.gz
mbim-device: trace transaction status within the MbimDevice
-rw-r--r--src/libmbim-glib/mbim-device.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libmbim-glib/mbim-device.c b/src/libmbim-glib/mbim-device.c
index d373a1e..d434665 100644
--- a/src/libmbim-glib/mbim-device.c
+++ b/src/libmbim-glib/mbim-device.c
@@ -39,6 +39,7 @@
#include "mbim-message.h"
#include "mbim-message-private.h"
#include "mbim-error-types.h"
+#include "mbim-enum-types.h"
#include "mbim-proxy.h"
#include "mbim-proxy-control.h"
@@ -150,6 +151,22 @@ typedef struct {
TransactionWaitContext *wait_ctx;
} Transaction;
+/* #define TRACE_TRANSACTION 1 */
+#ifdef TRACE_TRANSACTION
+static void
+trace_transaction (Transaction *tr,
+ const gchar *state)
+{
+ g_debug ("[%s,%u] transaction %s: %s",
+ tr->self->priv->path_display,
+ tr->transaction_id,
+ mbim_message_type_get_string (tr->type),
+ state);
+}
+#else
+# define trace_transaction(...)
+#endif
+
static Transaction *
transaction_new (MbimDevice *self,
MbimMessageType type,
@@ -171,6 +188,8 @@ transaction_new (MbimDevice *self,
if (cancellable)
tr->cancellable = g_object_ref (cancellable);
+ trace_transaction (tr, "new");
+
return tr;
}
@@ -191,10 +210,12 @@ transaction_complete_and_free (Transaction *tr,
g_slice_free (TransactionWaitContext, tr->wait_ctx);
if (error) {
+ trace_transaction (tr, "complete: response");
g_simple_async_result_set_from_error (tr->result, error);
if (tr->fragments)
mbim_message_unref (tr->fragments);
} else {
+ trace_transaction (tr, "complete: error");
g_assert (tr->fragments != NULL);
g_simple_async_result_set_op_res_gpointer (tr->result,
tr->fragments,
@@ -220,6 +241,7 @@ device_release_transaction (MbimDevice *self,
tr = g_hash_table_lookup (self->priv->transactions[type], GUINT_TO_POINTER (transaction_id));
if (tr && ((tr->type == expected_type) || (expected_type == MBIM_MESSAGE_TYPE_INVALID))) {
/* If found, remove it from the HT */
+ trace_transaction (tr, "release");
g_hash_table_remove (self->priv->transactions[type], GUINT_TO_POINTER (transaction_id));
return tr;
}
@@ -295,6 +317,8 @@ device_store_transaction (MbimDevice *self,
guint timeout_ms,
GError **error)
{
+ trace_transaction (tr, "store");
+
if (G_UNLIKELY (!self->priv->transactions[type]))
self->priv->transactions[type] = g_hash_table_new (g_direct_hash, g_direct_equal);