D-Bus: DBusPendingCall implementation details

D-Bus 1.12.20

Data Structures | Macros | Functions
DBusPendingCall implementation details
D-Bus secret internal implementation details

DBusPendingCall private implementation details. More...

## Data Structures
struct | DBusPendingCall
| Implementation details of DBusPendingCall - all fields are private. More...

## Macros
#define | CONNECTION_LOCK(connection) _dbus_connection_lock(connection)
| Internals of DBusPendingCall. More...
#define | CONNECTION_UNLOCK(connection) _dbus_connection_unlock(connection)
| shorter and more visible way to write _dbus_connection_unlock()

## Functions
DBusPendingCall * | _dbus_pending_call_new_unlocked (DBusConnection *connection, int timeout_milliseconds, DBusTimeoutHandler timeout_handler)
| Creates a new pending reply object. More...
void | _dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending, DBusMessage *message)
| Sets the reply of a pending call with the given message, or if the message is NULL, by timing out the pending call. More...
void | _dbus_pending_call_start_completion_unlocked (DBusPendingCall *pending)
| Sets the pending call to completed. More...
void | _dbus_pending_call_finish_completion (DBusPendingCall *pending)
| Call the notifier function for the pending call. More...
void | _dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending, DBusConnection *connection)
| If the pending call hasn't been timed out, add its timeout error reply to the connection's incoming message queue. More...
dbus_bool_t | _dbus_pending_call_is_timeout_added_unlocked (DBusPendingCall *pending)
| Checks to see if a timeout has been added. More...
void | _dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending, dbus_bool_t is_added)
| Sets wether the timeout has been added. More...
DBusTimeout * | _dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
| Retrives the timeout. More...
dbus_uint32_t | _dbus_pending_call_get_reply_serial_unlocked (DBusPendingCall *pending)
| Gets the reply's serial number. More...
void | _dbus_pending_call_set_reply_serial_unlocked (DBusPendingCall *pending, dbus_uint32_t serial)
| Sets the reply's serial number. More...
DBusConnection * | _dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
| Gets the connection associated with this pending call. More...
DBusConnection * | _dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending)
| Gets the connection associated with this pending call. More...
dbus_bool_t | _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending, DBusMessage *message, dbus_uint32_t serial)
| Sets the reply message associated with the pending call to a timeout error. More...
DBusPendingCall * | _dbus_pending_call_ref_unlocked (DBusPendingCall *pending)
| Increments the reference count on a pending call, while the lock on its connection is already held. More...
void | _dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
| Decrements the reference count on a pending call, freeing it if the count reaches 0. More...
dbus_bool_t | _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
| Checks whether the pending call has received a reply yet, or not. More...
dbus_bool_t | _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending, dbus_int32_t slot, void *data, DBusFreeFunction free_data_func)
| Stores a pointer on a DBusPendingCall, along with an optional function to be used for freeing the data when the data is set again, or when the pending call is finalized. More...

## Detailed Description

DBusPendingCall private implementation details.

The guts of DBusPendingCall and its methods.

## Macro Definition Documentation

## ◆ CONNECTION_LOCK

#define CONNECTION_LOCK | ( |  | connection | ) | _dbus_connection_lock(connection)

Internals of DBusPendingCall.

Opaque object representing a reply message that we're waiting for. shorter and more visible way to write _dbus_connection_lock()

Definition at line 54 of file dbus-pending-call.c.

## Function Documentation

## ◆ _dbus_pending_call_finish_completion()

void _dbus_pending_call_finish_completion | ( | DBusPendingCall * | pending | ) |

Call the notifier function for the pending call.

This method must be called after the connection lock has been released, and must be paired with a call to _dbus_pending_call_start_completion_unlocked().

Parameters

  pending | the pending call

Definition at line 232 of file dbus-pending-call.c.

References _dbus_assert, DBusPendingCall::completed, dbus_pending_call_get_data(), and DBusPendingCall::function.

## ◆ _dbus_pending_call_get_completed_unlocked()

dbus_bool_t _dbus_pending_call_get_completed_unlocked | ( | DBusPendingCall * | pending | ) |

Checks whether the pending call has received a reply yet, or not.

Assumes connection lock is held.

Parameters

  pending | the pending call

Returns
  TRUE if a reply has been received

Definition at line 506 of file dbus-pending-call.c.

References DBusPendingCall::completed.

## ◆ _dbus_pending_call_get_connection_and_lock()

DBusConnection* _dbus_pending_call_get_connection_and_lock | ( | DBusPendingCall * | pending | ) |

Gets the connection associated with this pending call.

Parameters

  pending | the pending_call

Returns
  the connection associated with the pending call

Definition at line 349 of file dbus-pending-call.c.

References _dbus_assert, DBusPendingCall::connection, CONNECTION_LOCK, and NULL.

Referenced by _dbus_connection_block_pending_call().

## ◆ _dbus_pending_call_get_connection_unlocked()

DBusConnection* _dbus_pending_call_get_connection_unlocked | ( | DBusPendingCall * | pending | ) |

Gets the connection associated with this pending call.

Parameters

  pending | the pending_call

Returns
  the connection associated with the pending call

Definition at line 364 of file dbus-pending-call.c.

References _dbus_assert, DBusPendingCall::connection, and NULL.

## ◆ _dbus_pending_call_get_reply_serial_unlocked()

dbus_uint32_t _dbus_pending_call_get_reply_serial_unlocked | ( | DBusPendingCall * | pending | ) |

Gets the reply's serial number.

Parameters

  pending | the pending_call

Returns
  a serial number for the reply or 0

Definition at line 319 of file dbus-pending-call.c.

References _dbus_assert, NULL, and DBusPendingCall::reply_serial.

## ◆ _dbus_pending_call_get_timeout_unlocked()

DBusTimeout* _dbus_pending_call_get_timeout_unlocked | ( | DBusPendingCall * | pending | ) |

Retrives the timeout.

Parameters

  pending | the pending_call

Returns
  a timeout object or NULL if call has no timeout

Definition at line 305 of file dbus-pending-call.c.

References _dbus_assert, NULL, and DBusPendingCall::timeout.

Referenced by _dbus_connection_queue_received_message_link().

## ◆ _dbus_pending_call_is_timeout_added_unlocked()

dbus_bool_t _dbus_pending_call_is_timeout_added_unlocked | ( | DBusPendingCall * | pending | ) |

Checks to see if a timeout has been added.

Parameters

  pending | the pending_call

Returns
  TRUE if there is a timeout or FALSE if not

Definition at line 274 of file dbus-pending-call.c.

References _dbus_assert, NULL, and DBusPendingCall::timeout_added.

Referenced by _dbus_connection_queue_received_message_link().

## ◆ _dbus_pending_call_new_unlocked()

DBusPendingCall* _dbus_pending_call_new_unlocked | ( | DBusConnection * | connection,
|  | int | timeout_milliseconds,
|  | DBusTimeoutHandler | timeout_handler
| ) |  |

Creates a new pending reply object.

Parameters

  connection | connection where reply will arrive
  timeout_milliseconds | length of timeout, -1 (or DBUS_TIMEOUT_USE_DEFAULT) for default, DBUS_TIMEOUT_INFINITE for no timeout
  timeout_handler | timeout handler, takes pending call as data

Returns
  a new DBusPendingCall or NULL if no memory.

Definition at line 117 of file dbus-pending-call.c.

References _dbus_assert, and dbus_pending_call_allocate_data_slot().

## ◆ _dbus_pending_call_queue_timeout_error_unlocked()

void _dbus_pending_call_queue_timeout_error_unlocked | ( | DBusPendingCall * | pending,
|  | DBusConnection * | connection
| ) |  |

If the pending call hasn't been timed out, add its timeout error reply to the connection's incoming message queue.

Parameters

  pending | the pending call
  connection | the connection the call was sent to

Definition at line 254 of file dbus-pending-call.c.

References _dbus_assert, _dbus_connection_queue_synthesized_message_link(), DBusPendingCall::connection, NULL, and DBusPendingCall::timeout_link.

## ◆ _dbus_pending_call_ref_unlocked()

DBusPendingCall* _dbus_pending_call_ref_unlocked | ( | DBusPendingCall * | pending | ) |

Increments the reference count on a pending call, while the lock on its connection is already held.

Parameters

  pending | the pending call object

Returns
  the pending call object

Definition at line 420 of file dbus-pending-call.c.

References _dbus_atomic_inc(), and DBusPendingCall::refcount.

## ◆ _dbus_pending_call_set_data_unlocked()

dbus_bool_t _dbus_pending_call_set_data_unlocked | ( | DBusPendingCall * | pending,
|  | dbus_int32_t | slot,
|  | void * | data,
|  | DBusFreeFunction | free_data_func
| ) |  |

Stores a pointer on a DBusPendingCall, along with an optional function to be used for freeing the data when the data is set again, or when the pending call is finalized.

The slot number must have been allocated with dbus_pending_call_allocate_data_slot().

Parameters

  pending | the pending_call
  slot | the slot number
  data | the data to store
  free_data_func | finalizer function for the data

Returns
  TRUE if there was enough memory to store the data

Definition at line 528 of file dbus-pending-call.c.

References _dbus_data_slot_list_set().

Referenced by dbus_pending_call_set_data(), and dbus_pending_call_set_notify().

## ◆ _dbus_pending_call_set_reply_serial_unlocked()

void _dbus_pending_call_set_reply_serial_unlocked | ( | DBusPendingCall * | pending,
|  | dbus_uint32_t | serial
| ) |  |

Sets the reply's serial number.

Parameters

  pending | the pending_call
  serial | the serial number

Definition at line 333 of file dbus-pending-call.c.

References _dbus_assert, NULL, and DBusPendingCall::reply_serial.

Referenced by _dbus_pending_call_set_timeout_error_unlocked().

## ◆ _dbus_pending_call_set_reply_unlocked()

void _dbus_pending_call_set_reply_unlocked | ( | DBusPendingCall * | pending,
|  | DBusMessage * | message
| ) |  |

Sets the reply of a pending call with the given message, or if the message is NULL, by timing out the pending call.

Parameters

  pending | the pending call
  message | the message to complete the call with, or NULL to time out the call

Definition at line 180 of file dbus-pending-call.c.

References _dbus_assert, _dbus_list_clear(), DBusList::data, dbus_message_get_reply_serial(), dbus_message_get_type(), dbus_message_ref(), DBUS_MESSAGE_TYPE_ERROR, DBUS_MESSAGE_TYPE_METHOD_RETURN, NULL, DBusPendingCall::reply, DBusPendingCall::reply_serial, and DBusPendingCall::timeout_link.

## ◆ _dbus_pending_call_set_timeout_added_unlocked()

void _dbus_pending_call_set_timeout_added_unlocked | ( | DBusPendingCall * | pending,
|  | dbus_bool_t | is_added
| ) |  |

Sets wether the timeout has been added.

Parameters

  pending | the pending_call
  is_added | whether or not a timeout is added

Definition at line 289 of file dbus-pending-call.c.

References _dbus_assert, NULL, and DBusPendingCall::timeout_added.

Referenced by _dbus_connection_queue_received_message_link().

## ◆ _dbus_pending_call_set_timeout_error_unlocked()

dbus_bool_t _dbus_pending_call_set_timeout_error_unlocked | ( | DBusPendingCall * | pending,
|  | DBusMessage * | message,
|  | dbus_uint32_t | serial
| ) |  |

Sets the reply message associated with the pending call to a timeout error.

Parameters

  pending | the pending_call
  message | the message we are sending the error reply to
  serial | serial number for the reply

Returns
  FALSE on OOM

Definition at line 380 of file dbus-pending-call.c.

References _dbus_list_alloc_link(), _dbus_pending_call_set_reply_serial_unlocked(), DBUS_ERROR_NO_REPLY, dbus_message_new_error(), dbus_message_unref(), FALSE, NULL, DBusPendingCall::timeout_link, and TRUE.

## ◆ _dbus_pending_call_start_completion_unlocked()

void _dbus_pending_call_start_completion_unlocked | ( | DBusPendingCall * | pending | ) |

Sets the pending call to completed.

This method is called with the connection lock held, to protect pending->completed. It must be paired with a call to _dbus_pending_call_finish_completion() after the connection lock has been released.

Parameters

  pending | the pending call

Definition at line 215 of file dbus-pending-call.c.

References _dbus_assert, DBusPendingCall::completed, and TRUE.

## ◆ _dbus_pending_call_unref_and_unlock()

void _dbus_pending_call_unref_and_unlock | ( | DBusPendingCall * | pending | ) |

Decrements the reference count on a pending call, freeing it if the count reaches 0.

Assumes connection lock is already held.

Parameters

  pending | the pending call object

Definition at line 483 of file dbus-pending-call.c.

References _dbus_assert, _dbus_atomic_dec(), and DBusPendingCall::refcount.