D-Bus 1.14.10
Functions

DBusCounter and other stuff related to resource limits. More...

Functions

DBusCounter_dbus_counter_new (void)
 Creates a new DBusCounter. More...
 
DBusCounter_dbus_counter_ref (DBusCounter *counter)
 Increments refcount of the counter. More...
 
void _dbus_counter_unref (DBusCounter *counter)
 Decrements refcount of the counter and possibly finalizes the counter. More...
 
void _dbus_counter_adjust_size (DBusCounter *counter, long delta)
 Adjusts the value of the size counter by the given delta which may be positive or negative. More...
 
void _dbus_counter_notify (DBusCounter *counter)
 Calls the notify function from _dbus_counter_set_notify(), if that function has been specified and the counter has crossed the guard value (in either direction) since the last call to this function. More...
 
void _dbus_counter_adjust_unix_fd (DBusCounter *counter, long delta)
 Adjusts the value of the unix fd counter by the given delta which may be positive or negative. More...
 
long _dbus_counter_get_size_value (DBusCounter *counter)
 Gets the current value of the size counter. More...
 
long _dbus_counter_get_unix_fd_value (DBusCounter *counter)
 Gets the current value of the unix fd counter. More...
 
void _dbus_counter_set_notify (DBusCounter *counter, long size_guard_value, long unix_fd_guard_value, DBusCounterNotifyFunction function, void *user_data)
 Sets the notify function for this counter; the notify function is called whenever the counter's values cross the guard values in either direction (moving up, or moving down). More...
 

Detailed Description

DBusCounter and other stuff related to resource limits.

Types and functions related to tracking resource limits, such as the maximum amount of memory/unix fds a connection can use for messages, etc.

Function Documentation

◆ _dbus_counter_adjust_size()

void _dbus_counter_adjust_size ( DBusCounter counter,
long  delta 
)

Adjusts the value of the size counter by the given delta which may be positive or negative.

This function may be called with locks held. After calling it, when any relevant locks are no longer held you must call _dbus_counter_notify().

Parameters
counterthe counter
deltavalue to add to the size counter's current value

Definition at line 167 of file dbus-resources.c.

References _dbus_rmutex_lock(), _dbus_rmutex_unlock(), DBusCounter::mutex, DBusCounter::notify_function, DBusCounter::notify_pending, DBusCounter::notify_size_guard_value, NULL, DBusCounter::size_value, and TRUE.

Referenced by _dbus_message_add_counter_link(), and _dbus_message_remove_counter().

◆ _dbus_counter_adjust_unix_fd()

void _dbus_counter_adjust_unix_fd ( DBusCounter counter,
long  delta 
)

Adjusts the value of the unix fd counter by the given delta which may be positive or negative.

This function may be called with locks held. After calling it, when any relevant locks are no longer held you must call _dbus_counter_notify().

Parameters
counterthe counter
deltavalue to add to the unix fds counter's current value

Definition at line 236 of file dbus-resources.c.

References _dbus_rmutex_lock(), _dbus_rmutex_unlock(), DBusCounter::mutex, DBusCounter::notify_function, DBusCounter::notify_pending, DBusCounter::notify_unix_fd_guard_value, NULL, TRUE, and DBusCounter::unix_fd_value.

Referenced by _dbus_message_add_counter_link(), and _dbus_message_remove_counter().

◆ _dbus_counter_get_size_value()

long _dbus_counter_get_size_value ( DBusCounter counter)

Gets the current value of the size counter.

Parameters
counterthe counter
Returns
its current size value

Definition at line 274 of file dbus-resources.c.

References _dbus_rmutex_lock(), _dbus_rmutex_unlock(), DBusCounter::mutex, and DBusCounter::size_value.

Referenced by _dbus_transport_get_dispatch_status(), and dbus_connection_get_outgoing_size().

◆ _dbus_counter_get_unix_fd_value()

long _dbus_counter_get_unix_fd_value ( DBusCounter counter)

Gets the current value of the unix fd counter.

Parameters
counterthe counter
Returns
its current unix fd value

Definition at line 290 of file dbus-resources.c.

References _dbus_rmutex_lock(), _dbus_rmutex_unlock(), DBusCounter::mutex, and DBusCounter::unix_fd_value.

Referenced by _dbus_transport_get_dispatch_status(), and dbus_connection_get_outgoing_unix_fds().

◆ _dbus_counter_new()

DBusCounter * _dbus_counter_new ( void  )

Creates a new DBusCounter.

DBusCounter is used to count usage of some resource such as memory.

Returns
new counter or NULL on failure

Definition at line 89 of file dbus-resources.c.

References _dbus_rmutex_new_at_location(), dbus_free(), dbus_new0, DBusCounter::mutex, NULL, and DBusCounter::refcount.

Referenced by _dbus_transport_init_base().

◆ _dbus_counter_notify()

void _dbus_counter_notify ( DBusCounter counter)

Calls the notify function from _dbus_counter_set_notify(), if that function has been specified and the counter has crossed the guard value (in either direction) since the last call to this function.

This function must not be called with locks held, since it can call out to user code.

Definition at line 207 of file dbus-resources.c.

References _dbus_rmutex_lock(), _dbus_rmutex_unlock(), FALSE, DBusCounter::mutex, DBusCounter::notify_data, DBusCounter::notify_function, DBusCounter::notify_pending, and NULL.

Referenced by _dbus_message_remove_counter().

◆ _dbus_counter_ref()

DBusCounter * _dbus_counter_ref ( DBusCounter counter)

Increments refcount of the counter.

Parameters
counterthe counter
Returns
the counter

Definition at line 116 of file dbus-resources.c.

References _dbus_assert, _dbus_rmutex_lock(), _dbus_rmutex_unlock(), DBusCounter::mutex, and DBusCounter::refcount.

Referenced by _dbus_message_add_counter().

◆ _dbus_counter_set_notify()

void _dbus_counter_set_notify ( DBusCounter counter,
long  size_guard_value,
long  unix_fd_guard_value,
DBusCounterNotifyFunction  function,
void *  user_data 
)

Sets the notify function for this counter; the notify function is called whenever the counter's values cross the guard values in either direction (moving up, or moving down).

Parameters
counterthe counter
size_guard_valuethe value we're notified if the size counter crosses
unix_fd_guard_valuethe value we're notified if the unix fd counter crosses
functionfunction to call in order to notify
user_datadata to pass to the function

Definition at line 311 of file dbus-resources.c.

References _dbus_rmutex_lock(), _dbus_rmutex_unlock(), FALSE, DBusCounter::mutex, DBusCounter::notify_data, DBusCounter::notify_function, DBusCounter::notify_pending, DBusCounter::notify_size_guard_value, and DBusCounter::notify_unix_fd_guard_value.

Referenced by _dbus_transport_finalize_base(), _dbus_transport_init_base(), _dbus_transport_set_max_received_size(), and _dbus_transport_set_max_received_unix_fds().

◆ _dbus_counter_unref()

void _dbus_counter_unref ( DBusCounter counter)