dbus_bool_t
bus_connections_check_limits (BusConnections *connections,
DBusConnection *requesting_completion,
+ const char **limit_name_out,
+ int *limit_out,
DBusError *error)
{
unsigned long uid;
+ int limit;
- if (connections->n_completed >=
- bus_context_get_max_completed_connections (connections->context))
+ limit = bus_context_get_max_completed_connections (connections->context);
+
+ if (connections->n_completed >= limit)
{
+ if (limit_name_out != NULL)
+ *limit_name_out = "max_completed_connections";
+
+ if (limit_out != NULL)
+ *limit_out = limit;
+
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
"The maximum number of active connections has been reached");
return FALSE;
if (dbus_connection_get_unix_user (requesting_completion, &uid))
{
- if (get_connections_for_uid (connections, uid) >=
- bus_context_get_max_connections_per_user (connections->context))
+ limit = bus_context_get_max_connections_per_user (connections->context);
+
+ if (get_connections_for_uid (connections, uid) >= limit)
{
+ if (limit_name_out != NULL)
+ *limit_name_out = "max_connections_per_user";
+
+ if (limit_out != NULL)
+ *limit_out = limit;
+
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
"The maximum number of active connections for UID %lu has been reached",
uid);
BusAppArmorConfinement* bus_connection_dup_apparmor_confinement (DBusConnection *connection);
dbus_bool_t bus_connections_check_limits (BusConnections *connections,
DBusConnection *requesting_completion,
+ const char **limit_name_out,
+ int *limit_out,
DBusError *error);
void bus_connections_expire_incomplete (BusConnections *connections);
dbus_bool_t retval;
BusRegistry *registry;
BusConnections *connections;
+ DBusError tmp_error;
+ int limit;
+ const char *limit_name;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
* incomplete connections. It's even OK if the connection wants to
* retry the hello message, we support that.
*/
+ dbus_error_init (&tmp_error);
connections = bus_connection_get_connections (connection);
if (!bus_connections_check_limits (connections, connection,
- error))
+ &limit_name, &limit,
+ &tmp_error))
{
- _DBUS_ASSERT_ERROR_IS_SET (error);
+ BusContext *context;
+
+ _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
+ context = bus_connection_get_context (connection);
+ bus_context_log (context, DBUS_SYSTEM_LOG_WARNING, "%s (%s=%d)",
+ tmp_error.message, limit_name, limit);
+ dbus_move_error (&tmp_error, error);
return FALSE;
}