From 73a3cf6d05ed26c5c62eb22ffa9146bdca446358 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Wed, 20 May 2020 16:32:23 +0900 Subject: [PATCH] Stats: Add field PendingReplies Pending replies will increasing 1) if client sending lots of messages to destination at once 2) if server eats incoming messages.(no reply) In case of 2) dbus-daemon still has pending information. With default bus context option (reply_timeout=-1) it never freed. Assuming 2) happended repeatedly, then it is hard to detect until it exceeds maximum pending replies limit, because of dbus-daemon print warning messages only if pending replies over bus limit(default 1024 for system bus). Change-Id: Iee0515fac68af7586547cc5ef5e6fa73d388a312 Signed-off-by: sanghyeok.oh --- bus/connection.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ bus/connection.h | 3 +++ bus/stats.c | 6 +++++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/bus/connection.c b/bus/connection.c index e1802e7..851fb1b 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -118,6 +118,7 @@ typedef struct #ifdef DBUS_ENABLE_STATS int peak_match_rules; int peak_bus_names; + int peak_pending_replies; #endif int n_pending_unix_fds; DBusTimeout *pending_unix_fds_timeout; @@ -2041,6 +2042,17 @@ bus_connections_expect_reply (BusConnections *connections, return FALSE; } +#ifdef DBUS_ENABLE_STATS + { + BusConnectionData *d; + + d = BUS_CONNECTION_DATA (will_get_reply); + _dbus_assert (d != NULL); + + update_peak(&d->peak_pending_replies, count); + } +#endif + pending = dbus_new0 (BusPendingReply, 1); if (pending == NULL) { @@ -2965,6 +2977,40 @@ bus_connection_get_peak_bus_names (DBusConnection *connection) return d->peak_bus_names; } + +int bus_connection_get_n_pending_replies (DBusConnection *connection) +{ + BusConnectionData *d; + DBusList *link; + BusPendingReply *pending; + int count = 0; + + d = BUS_CONNECTION_DATA (connection); + _dbus_assert(d != NULL); + + link = bus_expire_list_get_first_link(d->connections->pending_replies); + while (link != NULL) + { + pending = link->data; + link = bus_expire_list_get_next_link(d->connections->pending_replies, + link); + if (pending->will_get_reply == connection) + ++count; + } + + return count; +} + +int +bus_connection_get_peak_pending_replies (DBusConnection *connection) +{ + BusConnectionData *d; + + d = BUS_CONNECTION_DATA (connection); + _dbus_assert (d != NULL); + + return d->peak_pending_replies; +} #endif /* DBUS_ENABLE_STATS */ dbus_bool_t diff --git a/bus/connection.h b/bus/connection.h index ba7ce2f..868508a 100644 --- a/bus/connection.h +++ b/bus/connection.h @@ -194,4 +194,7 @@ int bus_connections_get_peak_bus_names_per_conn (BusConnections *connections); int bus_connection_get_peak_match_rules (DBusConnection *connection); int bus_connection_get_peak_bus_names (DBusConnection *connection); +int bus_connection_get_n_pending_replies (DBusConnection *connection); +int bus_connection_get_peak_pending_replies (DBusConnection *connection); + #endif /* BUS_CONNECTION_H */ diff --git a/bus/stats.c b/bus/stats.c index 2742235..367d9c1 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -170,7 +170,11 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, !_dbus_asv_add_uint32 (&arr_iter, "PeakBusNames", bus_connection_get_peak_bus_names (stats_connection)) || !_dbus_asv_add_string (&arr_iter, "UniqueName", - bus_connection_get_name (stats_connection))) + bus_connection_get_name (stats_connection)) || + !_dbus_asv_add_uint32 (&arr_iter, "PendingReplies", + bus_connection_get_n_pending_replies (stats_connection)) || + !_dbus_asv_add_uint32 (&arr_iter, "PeakPendingReplies", + bus_connection_get_peak_pending_replies (stats_connection))) { _dbus_asv_abandon (&iter, &arr_iter); goto oom; -- 2.7.4