summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-08 12:51:33 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-03-01 15:14:07 +0000
commitfddb83c6d4271393f710cac0399e8bf6319fd98e (patch)
tree5451a2c172ddb09ec3abf4c9a1837e823c2fd732
parent2b7707cc0db6528aa8623258645b2f57c27e7e09 (diff)
DBusConnection, DBusTransport: add queue statistics
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34040
-rw-r--r--dbus/dbus-connection-internal.h9
-rw-r--r--dbus/dbus-connection.c30
-rw-r--r--dbus/dbus-transport.c14
-rw-r--r--dbus/dbus-transport.h4
4 files changed, 57 insertions, 0 deletions
diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h
index cdf3f59d..60d51458 100644
--- a/dbus/dbus-connection-internal.h
+++ b/dbus/dbus-connection-internal.h
@@ -103,6 +103,15 @@ void _dbus_connection_test_get_locks (DBusConnectio
DBusCondVar **dispatch_cond_loc,
DBusCondVar **io_path_cond_loc);
+/* if DBUS_ENABLE_STATS */
+void _dbus_connection_get_stats (DBusConnection *connection,
+ dbus_uint32_t *in_messages,
+ dbus_uint32_t *in_bytes,
+ dbus_uint32_t *in_fds,
+ dbus_uint32_t *out_messages,
+ dbus_uint32_t *out_bytes,
+ dbus_uint32_t *out_fds);
+
/* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems
* silly for one function
*/
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 6779b6ae..83d19785 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -6198,6 +6198,36 @@ dbus_connection_get_outgoing_size (DBusConnection *connection)
return res;
}
+#ifdef DBUS_ENABLE_STATS
+void
+_dbus_connection_get_stats (DBusConnection *connection,
+ dbus_uint32_t *in_messages,
+ dbus_uint32_t *in_bytes,
+ dbus_uint32_t *in_fds,
+ dbus_uint32_t *out_messages,
+ dbus_uint32_t *out_bytes,
+ dbus_uint32_t *out_fds)
+{
+ CONNECTION_LOCK (connection);
+
+ if (in_messages != NULL)
+ *in_messages = connection->n_incoming;
+
+ _dbus_transport_get_stats (connection->transport, in_bytes, in_fds);
+
+ if (out_messages != NULL)
+ *out_messages = connection->n_outgoing;
+
+ if (out_bytes != NULL)
+ *out_bytes = _dbus_counter_get_size_value (connection->outgoing_counter);
+
+ if (out_fds != NULL)
+ *out_fds = _dbus_counter_get_unix_fd_value (connection->outgoing_counter);
+
+ CONNECTION_UNLOCK (connection);
+}
+#endif /* DBUS_ENABLE_STATS */
+
/**
* Gets the approximate number of uni fds of all messages in the
* outgoing message queue.
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index ba6bd4b4..8ab643bf 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -1482,4 +1482,18 @@ _dbus_transport_set_allow_anonymous (DBusTransport *transport,
transport->allow_anonymous = value != FALSE;
}
+#ifdef DBUS_ENABLE_STATS
+void
+_dbus_transport_get_stats (DBusTransport *transport,
+ dbus_uint32_t *queue_bytes,
+ dbus_uint32_t *queue_fds)
+{
+ if (queue_bytes != NULL)
+ *queue_bytes = _dbus_counter_get_size_value (transport->live_messages);
+
+ if (queue_fds != NULL)
+ *queue_fds = _dbus_counter_get_unix_fd_value (transport->live_messages);
+}
+#endif /* DBUS_ENABLE_STATS */
+
/** @} */
diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h
index 0db048a2..0aeab183 100644
--- a/dbus/dbus-transport.h
+++ b/dbus/dbus-transport.h
@@ -97,6 +97,10 @@ dbus_bool_t _dbus_transport_set_auth_mechanisms (DBusTransport
void _dbus_transport_set_allow_anonymous (DBusTransport *transport,
dbus_bool_t value);
+/* if DBUS_ENABLE_STATS */
+void _dbus_transport_get_stats (DBusTransport *transport,
+ dbus_uint32_t *queue_bytes,
+ dbus_uint32_t *queue_fds);
DBUS_END_DECLS