Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

DBusConnection implementation details
[D-BUS internal implementation details]

Implementation details of DBusConnection. More...

Data Structures

struct  DBusConnection
 Implementation details of DBusConnection. More...

struct  DBusMessageFilter
 Internal struct representing a message filter function. More...

struct  DBusPreallocatedSend
 Internals of DBusPreallocatedSend. More...


Typedefs

typedef DBusMessageFilter DBusMessageFilter
 Internal struct representing a message filter function.


Functions

void _dbus_connection_lock (DBusConnection *connection)
 Acquires the connection lock. More...

void _dbus_connection_unlock (DBusConnection *connection)
 Releases the connection lock. More...

dbus_bool_t _dbus_connection_queue_received_message (DBusConnection *connection, DBusMessage *message)
 Adds a message to the incoming message queue, returning FALSE if there's insufficient memory to queue the message. More...

void _dbus_connection_queue_received_message_link (DBusConnection *connection, DBusList *link)
 Adds a message-containing list link to the incoming message queue, taking ownership of the link and the message's current refcount. More...

dbus_bool_t _dbus_connection_have_messages_to_send (DBusConnection *connection)
 Checks whether there are messages in the outgoing message queue. More...

DBusMessage_dbus_connection_get_message_to_send (DBusConnection *connection)
 Gets the next outgoing message. More...

void _dbus_connection_message_sent (DBusConnection *connection, DBusMessage *message)
 Notifies the connection that a message has been sent, so the message can be removed from the outgoing queue. More...

dbus_bool_t _dbus_connection_add_watch (DBusConnection *connection, DBusWatch *watch)
 Adds a watch using the connection's DBusAddWatchFunction if available. More...

void _dbus_connection_remove_watch (DBusConnection *connection, DBusWatch *watch)
 Removes a watch using the connection's DBusRemoveWatchFunction if available. More...

void _dbus_connection_toggle_watch (DBusConnection *connection, DBusWatch *watch, dbus_bool_t enabled)
 Toggles a watch and notifies app via connection's DBusWatchToggledFunction if available. More...

dbus_bool_t _dbus_connection_add_timeout (DBusConnection *connection, DBusTimeout *timeout)
 Adds a timeout using the connection's DBusAddTimeoutFunction if available. More...

void _dbus_connection_remove_timeout (DBusConnection *connection, DBusTimeout *timeout)
 Removes a timeout using the connection's DBusRemoveTimeoutFunction if available. More...

void _dbus_connection_toggle_timeout (DBusConnection *connection, DBusTimeout *timeout, dbus_bool_t enabled)
 Toggles a timeout and notifies app via connection's DBusTimeoutToggledFunction if available. More...

void _dbus_connection_remove_pending_call (DBusConnection *connection, DBusPendingCall *pending)
 Removes a pending call from the connection, such that the pending reply will be ignored. More...

void _dbus_pending_call_complete_and_unlock (DBusPendingCall *pending, DBusMessage *message)
 Completes a pending call with the given message, or if the message is NULL, by timing out the pending call. More...

void _dbus_connection_do_iteration (DBusConnection *connection, unsigned int flags, int timeout_milliseconds)
 Queues incoming messages and sends outgoing messages for this connection, optionally blocking in the process. More...

DBusConnection_dbus_connection_new_for_transport (DBusTransport *transport)
 Creates a new connection for the given transport. More...

DBusConnection_dbus_connection_ref_unlocked (DBusConnection *connection)
 Increments the reference count of a DBusConnection. More...

void _dbus_connection_unref_unlocked (DBusConnection *connection)
 Decrements the reference count of a DBusConnection. More...

dbus_bool_t _dbus_connection_handle_watch (DBusWatch *watch, unsigned int condition, void *data)
 A callback for use with dbus_watch_new() to create a DBusWatch. More...


Detailed Description

Implementation details of DBusConnection.


Function Documentation

dbus_bool_t _dbus_connection_add_timeout DBusConnection   connection,
DBusTimeout   timeout
 

Adds a timeout using the connection's DBusAddTimeoutFunction if available.

Otherwise records the timeout to be added when said function is available. Also re-adds the timeout if the DBusAddTimeoutFunction changes. May fail due to lack of memory. The timeout will fire repeatedly until removed.

Parameters:
connection  the connection.
timeout  the timeout to add.
Returns:
TRUE on success.

Definition at line 530 of file dbus-connection.c.

References DBusConnection::timeouts.

dbus_bool_t _dbus_connection_add_watch DBusConnection   connection,
DBusWatch   watch
 

Adds a watch using the connection's DBusAddWatchFunction if available.

Otherwise records the watch to be added when said function is available. Also re-adds the watch if the DBusAddWatchFunction changes. May fail due to lack of memory.

Parameters:
connection  the connection.
watch  the watch to add.
Returns:
TRUE on success.

Definition at line 472 of file dbus-connection.c.

References DBusConnection::watches.

void _dbus_connection_do_iteration DBusConnection   connection,
unsigned int    flags,
int    timeout_milliseconds
 

Queues incoming messages and sends outgoing messages for this connection, optionally blocking in the process.

Each call to _dbus_connection_do_iteration() will call select() or poll() one time and then read or write data if possible.

The purpose of this function is to be able to flush outgoing messages or queue up incoming messages without returning control to the application and causing reentrancy weirdness.

The flags parameter allows you to specify whether to read incoming messages, write outgoing messages, or both, and whether to block if no immediate action is possible.

The timeout_milliseconds parameter does nothing unless the iteration is blocking.

If there are no outgoing messages and DBUS_ITERATION_DO_READING wasn't specified, then it's impossible to block, even if you specify DBUS_ITERATION_BLOCK; in that case the function returns immediately.

Parameters:
connection  the connection.
flags  iteration flags.
timeout_milliseconds  maximum blocking time, or -1 for no limit.

Definition at line 785 of file dbus-connection.c.

References DBusConnection::n_outgoing, and DBusConnection::transport.

DBusMessage* _dbus_connection_get_message_to_send DBusConnection   connection
 

Gets the next outgoing message.

The message remains in the queue, and the caller does not own a reference to it.

Parameters:
connection  the connection.
Returns:
the message to be sent.

Definition at line 408 of file dbus-connection.c.

References DBusConnection::outgoing_messages.

dbus_bool_t _dbus_connection_handle_watch DBusWatch   watch,
unsigned int    condition,
void *    data
 

A callback for use with dbus_watch_new() to create a DBusWatch.

Todo:
This is basically a hack - we could delete _dbus_transport_handle_watch() and the virtual handle_watch in DBusTransport if we got rid of it. The reason this is some work is threading, see the _dbus_connection_handle_watch() implementation.
Parameters:
watch  the watch.
condition  the current condition of the file descriptors being watched.
data  must be a pointer to a DBusConnection
Returns:
FALSE if the IO condition may not have been fully handled due to lack of memory

Definition at line 1044 of file dbus-connection.c.

References DBusConnection::transport.

dbus_bool_t _dbus_connection_have_messages_to_send DBusConnection   connection
 

Checks whether there are messages in the outgoing message queue.

Parameters:
connection  the connection.
Returns:
TRUE if the outgoing queue is non-empty.

Definition at line 395 of file dbus-connection.c.

References DBusConnection::outgoing_messages.

void _dbus_connection_lock DBusConnection   connection
 

Acquires the connection lock.

Parameters:
connection  the connection.

Definition at line 252 of file dbus-connection.c.

void _dbus_connection_message_sent DBusConnection   connection,
DBusMessage   message
 

Notifies the connection that a message has been sent, so the message can be removed from the outgoing queue.

Called with the connection lock held.

Parameters:
connection  the connection.
message  the message that was sent.

Definition at line 422 of file dbus-connection.c.

References DBusList::data, DBusConnection::link_cache, DBusConnection::n_outgoing, DBusConnection::outgoing_counter, DBusConnection::outgoing_messages, and DBusConnection::transport.

DBusConnection* _dbus_connection_new_for_transport DBusTransport   transport
 

Creates a new connection for the given transport.

A transport represents a message stream that uses some concrete mechanism, such as UNIX domain sockets. May return NULL if insufficient memory exists to create the connection.

Parameters:
transport  the transport.
Returns:
the new connection, or NULL on failure.

Definition at line 811 of file dbus-connection.c.

References DBusConnection::client_serial, DBusConnection::disconnect_message_link, DBusConnection::dispatch_cond, DBusConnection::exit_on_disconnect, DBusConnection::filter_list, DBusConnection::io_path_cond, DBusConnection::last_dispatch_status, DBusConnection::message_returned_cond, DBusConnection::mutex, DBusConnection::objects, DBusConnection::outgoing_counter, DBusConnection::pending_replies, DBusConnection::refcount, DBusConnection::slot_list, DBusConnection::timeouts, DBusConnection::transport, DBusAtomic::value, and DBusConnection::watches.

dbus_bool_t _dbus_connection_queue_received_message DBusConnection   connection,
DBusMessage   message
 

Adds a message to the incoming message queue, returning FALSE if there's insufficient memory to queue the message.

Does not take over refcount of the message.

Parameters:
connection  the connection.
message  the message to queue.
Returns:
TRUE on success.

Definition at line 294 of file dbus-connection.c.

void _dbus_connection_queue_received_message_link DBusConnection   connection,
DBusList   link
 

Adds a message-containing list link to the incoming message queue, taking ownership of the link and the message's current refcount.

Cannot fail due to lack of memory.

Parameters:
connection  the connection.
link  the message link to queue.

Definition at line 319 of file dbus-connection.c.

References DBusList::data, DBusConnection::incoming_messages, DBusConnection::n_incoming, DBusConnection::pending_replies, DBusPendingCall::timeout, DBusPendingCall::timeout_added, and DBusConnection::transport.

DBusConnection* _dbus_connection_ref_unlocked DBusConnection   connection
 

Increments the reference count of a DBusConnection.

Requires that the caller already holds the connection lock.

Parameters:
connection  the connection.
Returns:
the connection.

Definition at line 972 of file dbus-connection.c.

References DBusConnection::refcount, and DBusAtomic::value.

void _dbus_connection_remove_pending_call DBusConnection   connection,
DBusPendingCall   pending
 

Removes a pending call from the connection, such that the pending reply will be ignored.

May drop the last reference to the pending call.

Parameters:
connection  the connection
pending  the pending call

Definition at line 659 of file dbus-connection.c.

void _dbus_connection_remove_timeout DBusConnection   connection,
DBusTimeout   timeout
 

Removes a timeout using the connection's DBusRemoveTimeoutFunction if available.

It's an error to call this function on a timeout that was not previously added.

Parameters:
connection  the connection.
timeout  the timeout to remove.

Definition at line 549 of file dbus-connection.c.

References DBusConnection::timeouts.

void _dbus_connection_remove_watch DBusConnection   connection,
DBusWatch   watch
 

Removes a watch using the connection's DBusRemoveWatchFunction if available.

It's an error to call this function on a watch that was not previously added.

Parameters:
connection  the connection.
watch  the watch to remove.

Definition at line 491 of file dbus-connection.c.

References DBusConnection::watches.

void _dbus_connection_toggle_timeout DBusConnection   connection,
DBusTimeout   timeout,
dbus_bool_t    enabled
 

Toggles a timeout and notifies app via connection's DBusTimeoutToggledFunction if available.

It's an error to call this function on a timeout that was not previously added.

Parameters:
connection  the connection.
timeout  the timeout to toggle.
enabled  whether to enable or disable

Definition at line 576 of file dbus-connection.c.

References DBusConnection::timeouts.

void _dbus_connection_toggle_watch DBusConnection   connection,
DBusWatch   watch,
dbus_bool_t    enabled
 

Toggles a watch and notifies app via connection's DBusWatchToggledFunction if available.

It's an error to call this function on a watch that was not previously added.

Parameters:
connection  the connection.
watch  the watch to toggle.
enabled  whether to enable or disable

Definition at line 509 of file dbus-connection.c.

References DBusConnection::watches.

void _dbus_connection_unlock DBusConnection   connection
 

Releases the connection lock.

Parameters:
connection  the connection.

Definition at line 263 of file dbus-connection.c.

void _dbus_connection_unref_unlocked DBusConnection   connection
 

Decrements the reference count of a DBusConnection.

Requires that the caller already holds the connection lock.

Parameters:
connection  the connection.

Definition at line 991 of file dbus-connection.c.

References DBusConnection::refcount, and DBusAtomic::value.

void _dbus_pending_call_complete_and_unlock DBusPendingCall   pending,
DBusMessage   message
 

Completes 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 675 of file dbus-connection.c.

References DBusPendingCall::connection, DBusList::data, DBusPendingCall::reply, DBusPendingCall::reply_serial, and DBusPendingCall::timeout_link.


Generated on Wed Jun 9 05:01:27 2004 for D-BUS by doxygen1.2.15