From 47bacd75e70463f0d28a66dc388fdc9cd7032243 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Feb 2011 15:48:12 +0000 Subject: [PATCH 10/10] Include size of link cache in per-connection statistics Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34040 --- bus/stats.c | 7 +++++-- dbus/dbus-connection-internal.h | 3 ++- dbus/dbus-connection.c | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bus/stats.c b/bus/stats.c index 28fd49b..4e72885 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -263,6 +263,7 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, static dbus_uint32_t stats_serial = 0; dbus_uint32_t in_messages, in_bytes, in_fds, in_peak_bytes, in_peak_fds; dbus_uint32_t out_messages, out_bytes, out_fds, out_peak_bytes, out_peak_fds; + dbus_uint32_t link_cache_bytes; BusRegistry *registry; BusService *service; DBusConnection *stats_connection; @@ -315,7 +316,8 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, &in_messages, &in_bytes, &in_fds, &in_peak_bytes, &in_peak_fds, &out_messages, &out_bytes, &out_fds, - &out_peak_bytes, &out_peak_fds); + &out_peak_bytes, &out_peak_fds, + &link_cache_bytes); if (!asv_add_uint32 (&iter, &arr_iter, "IncomingMessages", in_messages) || !asv_add_uint32 (&iter, &arr_iter, "IncomingBytes", in_bytes) || @@ -326,7 +328,8 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, !asv_add_uint32 (&iter, &arr_iter, "OutgoingBytes", out_bytes) || !asv_add_uint32 (&iter, &arr_iter, "OutgoingFDs", out_fds) || !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingBytes", out_peak_bytes) || - !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingFDs", out_peak_fds)) + !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingFDs", out_peak_fds) || + !asv_add_uint32 (&iter, &arr_iter, "LinkCacheBytes", link_cache_bytes)) goto oom; /* end */ diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h index 3dc5989..e55cb66 100644 --- a/dbus/dbus-connection-internal.h +++ b/dbus/dbus-connection-internal.h @@ -114,7 +114,8 @@ void _dbus_connection_get_stats (DBusConnection *connection, dbus_uint32_t *out_bytes, dbus_uint32_t *out_fds, dbus_uint32_t *out_peak_bytes, - dbus_uint32_t *out_peak_fds); + dbus_uint32_t *out_peak_fds, + dbus_uint32_t *link_cache_size); /* 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 7d5a8ef..59f5337 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -6210,7 +6210,8 @@ _dbus_connection_get_stats (DBusConnection *connection, dbus_uint32_t *out_bytes, dbus_uint32_t *out_fds, dbus_uint32_t *out_peak_bytes, - dbus_uint32_t *out_peak_fds) + dbus_uint32_t *out_peak_fds, + dbus_uint32_t *link_cache_size) { CONNECTION_LOCK (connection); @@ -6235,6 +6236,11 @@ _dbus_connection_get_stats (DBusConnection *connection, if (out_peak_fds != NULL) *out_peak_fds = _dbus_counter_get_peak_unix_fd_value (connection->outgoing_counter); + if (link_cache_size != NULL) + { + *link_cache_size = _dbus_list_get_length (&connection->link_cache) * sizeof (DBusList); + } + CONNECTION_UNLOCK (connection); } #endif /* DBUS_ENABLE_STATS */ -- 1.7.2.3