From 789fe3debfb813aee406cf1ab20a808333c5657a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 18 Nov 2014 19:19:16 +0000 Subject: [PATCH 09/11] Log when we exceed max_match_rules_per_connection --- bus/driver.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index f477686..1d2ff11 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1005,21 +1005,32 @@ bus_driver_handle_add_match (DBusConnection *connection, const char *text; DBusString str; BusMatchmaker *matchmaker; + int limit; + BusContext *context; _DBUS_ASSERT_ERROR_IS_CLEAR (error); text = NULL; rule = NULL; - if (bus_connection_get_n_match_rules (connection) >= - bus_context_get_max_match_rules_per_connection (bus_transaction_get_context (transaction))) + context = bus_transaction_get_context (transaction); + limit = bus_context_get_max_match_rules_per_connection (context); + + if (bus_connection_get_n_match_rules (connection) >= limit) { - dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED, + DBusError tmp_error; + + dbus_error_init (&tmp_error); + dbus_set_error (&tmp_error, DBUS_ERROR_LIMITS_EXCEEDED, "Connection \"%s\" is not allowed to add more match rules " - "(increase limits in configuration file if required)", + "(increase limits in configuration file if required; " + "max_match_rules_per_connection=%d)", bus_connection_is_active (connection) ? bus_connection_get_name (connection) : - "(inactive)"); + "(inactive)", + limit); + bus_context_log (context, DBUS_SYSTEM_LOG_WARNING, "%s", tmp_error.message); + dbus_move_error (&tmp_error, error); goto failed; } -- 2.1.3