From 03c363ace217b4bed4e282a5c043f0552b9e2c8f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 10 Mar 2011 04:10:31 +0100 Subject: [PATCH] connection: hook UnknownObject and UnknownInterface up where appropriate This makes use of UnknownInterface and UnknownObject where appropriate in the D-Bus core. --- bus/driver.c | 5 +- dbus/dbus-connection.c | 824 ++++++++++++++++++++++++----------------------- dbus/dbus-object-tree.c | 148 +++++---- dbus/dbus-object-tree.h | 7 +- 4 files changed, 497 insertions(+), 487 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index cc8d1f2..6016b23 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1963,7 +1963,10 @@ bus_driver_handle_message (DBusConnection *connection, { _dbus_verbose ("Driver got message to unknown interface \"%s\"\n", interface); - goto unknown; + dbus_set_error (error, DBUS_ERROR_UNKNOWN_INTERFACE, + "%s does not understand message to interface %s", + DBUS_SERVICE_DBUS, interface); + return FALSE; } _dbus_verbose ("Driver got a method call: %s\n", diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 6779b6a..8968e03 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -4,7 +4,7 @@ * Copyright (C) 2002-2006 Red Hat Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -99,7 +99,7 @@ * The other application may be a message bus; for convenience, the * function dbus_bus_get() is provided to automatically open a * connection to the well-known message buses. - * + * * In brief a DBusConnection is a message queue associated with some * message transport mechanism such as a socket. The connection * maintains a queue of incoming messages and a queue of outgoing @@ -121,17 +121,17 @@ * The connection provides #DBusWatch and #DBusTimeout objects to * the main loop. These are used to know when reading, writing, or * dispatching should be performed. - * + * * Incoming messages are processed * by calling dbus_connection_dispatch(). dbus_connection_dispatch() * runs any handlers registered for the topmost message in the message * queue, then discards the message, then returns. - * + * * dbus_connection_get_dispatch_status() indicates whether * messages are currently in the queue that need dispatching. * dbus_connection_set_dispatch_status_function() allows * you to set a function to be used to monitor the dispatch status. - * + * * If you're using GLib or Qt add-on libraries for D-Bus, there are * special convenience APIs in those libraries that hide * all the details of dispatch and watch/timeout monitoring. @@ -154,7 +154,7 @@ * avoid setting up any handler functions (see * dbus_connection_add_filter(), * dbus_connection_register_object_path() for more on handlers). - * + * * When you use dbus_connection_send() or one of its variants to send * a message, the message is added to the outgoing queue. It's * actually written to the network later; either in @@ -207,12 +207,12 @@ */ /** - * Internal struct representing a message filter function + * Internal struct representing a message filter function */ typedef struct DBusMessageFilter DBusMessageFilter; /** - * Internal struct representing a message filter function + * Internal struct representing a message filter function */ struct DBusMessageFilter { @@ -252,30 +252,30 @@ struct DBusConnection DBusCondVar *dispatch_cond; /**< Notify when dispatch_acquired is available */ DBusMutex *io_path_mutex; /**< Protects io_path_acquired */ DBusCondVar *io_path_cond; /**< Notify when io_path_acquired is available */ - + DBusList *outgoing_messages; /**< Queue of messages we need to send, send the end of the list first. */ DBusList *incoming_messages; /**< Queue of messages we have received, end of the list received most recently. */ DBusMessage *message_borrowed; /**< Filled in if the first incoming message has been borrowed; * dispatch_acquired will be set by the borrower */ - + int n_outgoing; /**< Length of outgoing queue. */ int n_incoming; /**< Length of incoming queue. */ DBusCounter *outgoing_counter; /**< Counts size of outgoing messages. */ - + DBusTransport *transport; /**< Object that sends/receives messages over network. */ DBusWatchList *watches; /**< Stores active watches. */ DBusTimeoutList *timeouts; /**< Stores active timeouts. */ - + DBusList *filter_list; /**< List of filters. */ DBusMutex *slot_mutex; /**< Lock on slot_list so overall connection lock need not be taken */ DBusDataSlotList slot_list; /**< Data stored by allocated integer ID */ - DBusHashTable *pending_replies; /**< Hash of message serials to #DBusPendingCall. */ - + DBusHashTable *pending_replies; /**< Hash of message serials to #DBusPendingCall. */ + dbus_uint32_t client_serial; /**< Client serial. Increments each time a message is sent */ DBusList *disconnect_message_link; /**< Preallocated list node for queueing the disconnection message */ @@ -302,9 +302,9 @@ struct DBusConnection */ dbus_bool_t dispatch_acquired; /**< Someone has dispatch path (can drain incoming queue) */ dbus_bool_t io_path_acquired; /**< Someone has transport io path (can use the transport to read/write messages) */ - + unsigned int shareable : 1; /**< #TRUE if libdbus owns a reference to the connection and can return it from dbus_connection_open() more than once */ - + unsigned int exit_on_disconnect : 1; /**< If #TRUE, exit after handling disconnect signal */ unsigned int route_peer_messages : 1; /**< If #TRUE, if org.freedesktop.DBus.Peer messages have a bus name, don't handle them automatically */ @@ -316,14 +316,14 @@ struct DBusConnection unsigned int disconnected_message_processed : 1; /**< We did our default handling of the disconnected message, * such as closing the connection. */ - + #ifndef DBUS_DISABLE_CHECKS unsigned int have_connection_lock : 1; /**< Used to check locking */ #endif - + #ifndef DBUS_DISABLE_CHECKS int generation; /**< _dbus_current_generation that should correspond to this connection */ -#endif +#endif }; static DBusDispatchStatus _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection); @@ -356,7 +356,7 @@ _dbus_message_filter_unref (DBusMessageFilter *filter) { if (filter->free_user_data_function) (* filter->free_user_data_function) (filter->user_data); - + dbus_free (filter); } } @@ -431,12 +431,12 @@ _dbus_connection_queue_received_message (DBusConnection *connection, * @param mutex_loc return for the location of the main mutex pointer * @param dispatch_mutex_loc return location of the dispatch mutex pointer * @param io_path_mutex_loc return location of the io_path mutex pointer - * @param dispatch_cond_loc return location of the dispatch conditional + * @param dispatch_cond_loc return location of the dispatch conditional * variable pointer - * @param io_path_cond_loc return location of the io_path conditional + * @param io_path_cond_loc return location of the io_path conditional * variable pointer - */ -void + */ +void _dbus_connection_test_get_locks (DBusConnection *connection, DBusMutex **mutex_loc, DBusMutex **dispatch_mutex_loc, @@ -446,7 +446,7 @@ _dbus_connection_test_get_locks (DBusConnection *connection, { *mutex_loc = connection->mutex; *dispatch_mutex_loc = connection->dispatch_mutex; - *io_path_mutex_loc = connection->io_path_mutex; + *io_path_mutex_loc = connection->io_path_mutex; *dispatch_cond_loc = connection->dispatch_cond; *io_path_cond_loc = connection->io_path_cond; } @@ -467,9 +467,9 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection, DBusPendingCall *pending; dbus_uint32_t reply_serial; DBusMessage *message; - + _dbus_assert (_dbus_transport_get_is_authenticated (connection->transport)); - + _dbus_list_append_link (&connection->incoming_messages, link); message = link->data; @@ -489,13 +489,13 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection, _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); } } - - + + connection->n_incoming += 1; _dbus_connection_wakeup_mainloop (connection); - + _dbus_verbose ("Message %p (%s %s %s %s '%s' reply to %u) added to incoming queue %p, %d incoming\n", message, dbus_message_type_to_string (dbus_message_get_type (message)), @@ -526,13 +526,13 @@ _dbus_connection_queue_synthesized_message_link (DBusConnection *connection, DBusList *link) { HAVE_LOCK_CHECK (connection); - + _dbus_list_append_link (&connection->incoming_messages, link); connection->n_incoming += 1; _dbus_connection_wakeup_mainloop (connection); - + _dbus_verbose ("Synthesized message %p added to incoming queue %p, %d incoming\n", link->data, connection, connection->n_incoming); } @@ -557,7 +557,7 @@ _dbus_connection_has_messages_to_send_unlocked (DBusConnection *connection) * Use dbus_connection_flush() to block until all outgoing * messages have been written to the underlying transport * (such as a socket). - * + * * @param connection the connection. * @returns #TRUE if the outgoing queue is non-empty. */ @@ -565,7 +565,7 @@ dbus_bool_t dbus_connection_has_messages_to_send (DBusConnection *connection) { dbus_bool_t v; - + _dbus_return_val_if_fail (connection != NULL, FALSE); CONNECTION_LOCK (connection); @@ -581,12 +581,12 @@ dbus_connection_has_messages_to_send (DBusConnection *connection) * * @param connection the connection. * @returns the message to be sent. - */ + */ DBusMessage* _dbus_connection_get_message_to_send (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + return _dbus_list_get_last (&connection->outgoing_messages); } @@ -605,12 +605,12 @@ _dbus_connection_message_sent (DBusConnection *connection, DBusList *link; HAVE_LOCK_CHECK (connection); - + /* This can be called before we even complete authentication, since * it's called on disconnect to clean up the outgoing queue. * It's also called as we successfully send each message. */ - + link = _dbus_list_get_last_link (&connection->outgoing_messages); _dbus_assert (link != NULL); _dbus_assert (link->data == message); @@ -619,7 +619,7 @@ _dbus_connection_message_sent (DBusConnection *connection, _dbus_list_unlink (&connection->outgoing_messages, link); _dbus_list_prepend_link (&connection->link_cache, link); - + connection->n_outgoing -= 1; _dbus_verbose ("Message %p (%s %s %s %s '%s') removed from outgoing queue %p, %d left to send\n", @@ -641,7 +641,7 @@ _dbus_connection_message_sent (DBusConnection *connection, _dbus_message_remove_counter (message, connection->outgoing_counter, &link); _dbus_list_prepend_link (&connection->link_cache, link); - + dbus_message_unref (message); } @@ -705,7 +705,7 @@ protected_change_watch (DBusConnection *connection, else return FALSE; } - + /** * Adds a watch using the connection's DBusAddWatchFunction if @@ -910,7 +910,7 @@ _dbus_connection_attach_pending_call_unlocked (DBusConnection *connection, { if (!_dbus_connection_add_timeout_unlocked (connection, timeout)) return FALSE; - + if (!_dbus_hash_table_insert_int (connection->pending_replies, reply_serial, pending)) @@ -921,7 +921,7 @@ _dbus_connection_attach_pending_call_unlocked (DBusConnection *connection, HAVE_LOCK_CHECK (connection); return FALSE; } - + _dbus_pending_call_set_timeout_added_unlocked (pending, TRUE); } else @@ -938,7 +938,7 @@ _dbus_connection_attach_pending_call_unlocked (DBusConnection *connection, _dbus_pending_call_ref_unlocked (pending); HAVE_LOCK_CHECK (connection); - + return TRUE; } @@ -947,7 +947,7 @@ free_pending_call_on_hash_removal (void *data) { DBusPendingCall *pending; DBusConnection *connection; - + if (data == NULL) return; @@ -956,18 +956,18 @@ free_pending_call_on_hash_removal (void *data) connection = _dbus_pending_call_get_connection_unlocked (pending); HAVE_LOCK_CHECK (connection); - + if (_dbus_pending_call_is_timeout_added_unlocked (pending)) { _dbus_connection_remove_timeout_unlocked (connection, _dbus_pending_call_get_timeout_unlocked (pending)); - + _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); } - /* FIXME 1.0? this is sort of dangerous and undesirable to drop the lock - * here, but the pending call finalizer could in principle call out to - * application code so we pretty much have to... some larger code reorg + /* FIXME 1.0? this is sort of dangerous and undesirable to drop the lock + * here, but the pending call finalizer could in principle call out to + * application code so we pretty much have to... some larger code reorg * might be needed. */ _dbus_connection_ref_unlocked (connection); @@ -1041,7 +1041,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, int timeout_milliseconds) { dbus_bool_t we_acquired; - + HAVE_LOCK_CHECK (connection); /* We don't want the connection to vanish */ @@ -1049,7 +1049,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, /* We will only touch io_path_acquired which is protected by our mutex */ CONNECTION_UNLOCK (connection); - + _dbus_verbose ("locking io_path_mutex\n"); _dbus_mutex_lock (connection->io_path_mutex); @@ -1057,7 +1057,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, connection->io_path_acquired, timeout_milliseconds); we_acquired = FALSE; - + if (connection->io_path_acquired) { if (timeout_milliseconds != -1) @@ -1084,18 +1084,18 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, while (connection->io_path_acquired) { _dbus_verbose ("waiting for IO path to be acquirable\n"); - _dbus_condvar_wait (connection->io_path_cond, + _dbus_condvar_wait (connection->io_path_cond, connection->io_path_mutex); } } } - + if (!connection->io_path_acquired) { we_acquired = TRUE; connection->io_path_acquired = TRUE; } - + _dbus_verbose ("end connection->io_path_acquired = %d we_acquired = %d\n", connection->io_path_acquired, we_acquired); @@ -1103,11 +1103,11 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, _dbus_mutex_unlock (connection->io_path_mutex); CONNECTION_LOCK (connection); - + HAVE_LOCK_CHECK (connection); _dbus_connection_unref_unlocked (connection); - + return we_acquired; } @@ -1122,15 +1122,15 @@ static void _dbus_connection_release_io_path (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + _dbus_verbose ("locking io_path_mutex\n"); _dbus_mutex_lock (connection->io_path_mutex); - + _dbus_assert (connection->io_path_acquired); _dbus_verbose ("start connection->io_path_acquired = %d\n", connection->io_path_acquired); - + connection->io_path_acquired = FALSE; _dbus_condvar_wake_one (connection->io_path_cond); @@ -1167,7 +1167,7 @@ _dbus_connection_release_io_path (DBusConnection *connection) * lock for a while. * * Called with connection lock held. - * + * * @param connection the connection. * @param pending the pending call that should be checked or NULL * @param flags iteration flags. @@ -1180,9 +1180,9 @@ _dbus_connection_do_iteration_unlocked (DBusConnection *connection, int timeout_milliseconds) { _dbus_verbose ("start\n"); - + HAVE_LOCK_CHECK (connection); - + if (connection->n_outgoing == 0) flags &= ~DBUS_ITERATION_DO_WRITING; @@ -1190,7 +1190,7 @@ _dbus_connection_do_iteration_unlocked (DBusConnection *connection, (flags & DBUS_ITERATION_BLOCK) ? timeout_milliseconds : 0)) { HAVE_LOCK_CHECK (connection); - + if ( (pending != NULL) && _dbus_pending_call_get_completed_unlocked(pending)) { _dbus_verbose ("pending call completed while acquiring I/O path"); @@ -1235,7 +1235,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) DBusMessage *disconnect_message; DBusCounter *outgoing_counter; DBusObjectTree *objects; - + watch_list = NULL; connection = NULL; pending_replies = NULL; @@ -1244,14 +1244,14 @@ _dbus_connection_new_for_transport (DBusTransport *transport) disconnect_message = NULL; outgoing_counter = NULL; objects = NULL; - + watch_list = _dbus_watch_list_new (); if (watch_list == NULL) goto error; timeout_list = _dbus_timeout_list_new (); if (timeout_list == NULL) - goto error; + goto error; pending_replies = _dbus_hash_table_new (DBUS_HASH_INT, @@ -1259,7 +1259,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) (DBusFreeFunction)free_pending_call_on_hash_removal); if (pending_replies == NULL) goto error; - + connection = dbus_new0 (DBusConnection, 1); if (connection == NULL) goto error; @@ -1275,11 +1275,11 @@ _dbus_connection_new_for_transport (DBusTransport *transport) _dbus_mutex_new_at_location (&connection->dispatch_mutex); if (connection->dispatch_mutex == NULL) goto error; - + _dbus_condvar_new_at_location (&connection->dispatch_cond); if (connection->dispatch_cond == NULL) goto error; - + _dbus_condvar_new_at_location (&connection->io_path_cond); if (connection->io_path_cond == NULL) goto error; @@ -1291,7 +1291,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) disconnect_message = dbus_message_new_signal (DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL, "Disconnected"); - + if (disconnect_message == NULL) goto error; @@ -1306,10 +1306,10 @@ _dbus_connection_new_for_transport (DBusTransport *transport) objects = _dbus_object_tree_new (connection); if (objects == NULL) goto error; - + if (_dbus_modify_sigpipe) _dbus_disable_sigpipe (); - + connection->refcount.value = 1; connection->transport = transport; connection->watches = watch_list; @@ -1324,11 +1324,11 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->route_peer_messages = FALSE; connection->disconnected_message_arrived = FALSE; connection->disconnected_message_processed = FALSE; - + #ifndef DBUS_DISABLE_CHECKS connection->generation = _dbus_current_generation; #endif - + _dbus_data_slot_list_init (&connection->slot_list); connection->client_serial = 1; @@ -1336,7 +1336,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->disconnect_message_link = disconnect_link; CONNECTION_LOCK (connection); - + if (!_dbus_transport_set_connection (transport, connection)) { CONNECTION_UNLOCK (connection); @@ -1347,16 +1347,16 @@ _dbus_connection_new_for_transport (DBusTransport *transport) _dbus_transport_ref (transport); CONNECTION_UNLOCK (connection); - + return connection; - + error: if (disconnect_message != NULL) dbus_message_unref (disconnect_message); - + if (disconnect_link != NULL) _dbus_list_free_link (disconnect_link); - + if (connection != NULL) { _dbus_condvar_free_at_location (&connection->io_path_cond); @@ -1369,7 +1369,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) } if (pending_replies) _dbus_hash_table_unref (pending_replies); - + if (watch_list) _dbus_watch_list_free (watch_list); @@ -1381,7 +1381,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) if (objects) _dbus_object_tree_unref (objects); - + return NULL; } @@ -1394,12 +1394,12 @@ _dbus_connection_new_for_transport (DBusTransport *transport) */ DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection) -{ +{ _dbus_assert (connection != NULL); _dbus_assert (connection->generation == _dbus_current_generation); HAVE_LOCK_CHECK (connection); - + #ifdef DBUS_HAVE_ATOMIC_INT _dbus_atomic_inc (&connection->refcount); #else @@ -1422,25 +1422,25 @@ _dbus_connection_unref_unlocked (DBusConnection *connection) dbus_bool_t last_unref; HAVE_LOCK_CHECK (connection); - + _dbus_assert (connection != NULL); /* The connection lock is better than the global * lock in the atomic increment fallback */ - + #ifdef DBUS_HAVE_ATOMIC_INT last_unref = (_dbus_atomic_dec (&connection->refcount) == 1); #else _dbus_assert (connection->refcount.value > 0); connection->refcount.value -= 1; - last_unref = (connection->refcount.value == 0); + last_unref = (connection->refcount.value == 0); #if 0 printf ("unref_unlocked() connection %p count = %d\n", connection, connection->refcount.value); #endif #endif - + if (last_unref) _dbus_connection_last_unref (connection); } @@ -1460,7 +1460,7 @@ _dbus_connection_get_next_client_serial (DBusConnection *connection) /** * 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() @@ -1483,7 +1483,7 @@ _dbus_connection_handle_watch (DBusWatch *watch, connection = data; _dbus_verbose ("start\n"); - + CONNECTION_LOCK (connection); if (!_dbus_connection_acquire_io_path (connection, 1)) @@ -1502,14 +1502,14 @@ _dbus_connection_handle_watch (DBusWatch *watch, HAVE_LOCK_CHECK (connection); _dbus_verbose ("middle\n"); - + status = _dbus_connection_get_dispatch_status_unlocked (connection); /* this calls out to user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); _dbus_verbose ("end\n"); - + return retval; } @@ -1537,18 +1537,18 @@ static void shared_connections_shutdown (void *data) { int n_entries; - + _DBUS_LOCK (shared_connections); - + /* This is a little bit unpleasant... better ideas? */ while ((n_entries = _dbus_hash_table_get_n_entries (shared_connections)) > 0) { DBusConnection *connection; DBusHashIter iter; - + _dbus_hash_iter_init (shared_connections, &iter); _dbus_hash_iter_next (&iter); - + connection = _dbus_hash_iter_get_value (&iter); _DBUS_UNLOCK (shared_connections); @@ -1560,7 +1560,7 @@ shared_connections_shutdown (void *data) } _dbus_assert (_dbus_hash_table_get_n_entries (shared_connections) == 0); - + _dbus_hash_table_unref (shared_connections); shared_connections = NULL; @@ -1578,7 +1578,7 @@ shared_connections_shutdown (void *data) } shared_connections_no_guid = NULL; - + _DBUS_UNLOCK (shared_connections); } @@ -1587,15 +1587,15 @@ connection_lookup_shared (DBusAddressEntry *entry, DBusConnection **result) { _dbus_verbose ("checking for existing connection\n"); - + *result = NULL; - + _DBUS_LOCK (shared_connections); if (shared_connections == NULL) { _dbus_verbose ("creating shared_connections hash table\n"); - + shared_connections = _dbus_hash_table_new (DBUS_HASH_STRING, dbus_free, NULL); @@ -1614,7 +1614,7 @@ connection_lookup_shared (DBusAddressEntry *entry, } _dbus_verbose (" successfully created shared_connections\n"); - + _DBUS_UNLOCK (shared_connections); return TRUE; /* no point looking up in the hash we just made */ } @@ -1623,11 +1623,11 @@ connection_lookup_shared (DBusAddressEntry *entry, const char *guid; guid = dbus_address_entry_get_value (entry, "guid"); - + if (guid != NULL) { DBusConnection *connection; - + connection = _dbus_hash_table_lookup_string (shared_connections, guid); @@ -1663,7 +1663,7 @@ connection_lookup_shared (DBusAddressEntry *entry, CONNECTION_UNLOCK (connection); } } - + _DBUS_UNLOCK (shared_connections); return TRUE; } @@ -1699,12 +1699,12 @@ connection_record_shared_unlocked (DBusConnection *connection, _DBUS_UNLOCK (shared_connections); return TRUE; /* don't store in the hash */ } - + /* A separate copy of the key is required in the hash table, because * we don't have a lock on the connection when we are doing a hash * lookup. */ - + guid_key = _dbus_strdup (guid); if (guid_key == NULL) return FALSE; @@ -1715,10 +1715,10 @@ connection_record_shared_unlocked (DBusConnection *connection, dbus_free (guid_key); return FALSE; } - + _DBUS_LOCK (shared_connections); _dbus_assert (shared_connections != NULL); - + if (!_dbus_hash_table_insert_string (shared_connections, guid_key, connection)) { @@ -1732,11 +1732,11 @@ connection_record_shared_unlocked (DBusConnection *connection, _dbus_verbose ("stored connection to %s to be shared\n", connection->server_guid); - + _DBUS_UNLOCK (shared_connections); _dbus_assert (connection->server_guid != NULL); - + return TRUE; } @@ -1747,18 +1747,18 @@ connection_forget_shared_unlocked (DBusConnection *connection) if (!connection->shareable) return; - + _DBUS_LOCK (shared_connections); - + if (connection->server_guid != NULL) { _dbus_verbose ("dropping connection to %s out of the shared table\n", connection->server_guid); - + if (!_dbus_hash_table_remove_string (shared_connections, connection->server_guid)) _dbus_assert_not_reached ("connection was not in the shared table"); - + dbus_free (connection->server_guid); connection->server_guid = NULL; } @@ -1768,7 +1768,7 @@ connection_forget_shared_unlocked (DBusConnection *connection) } _DBUS_UNLOCK (shared_connections); - + /* remove our reference held on all shareable connections */ _dbus_connection_unref_unlocked (connection); } @@ -1791,7 +1791,7 @@ connection_try_from_address_entry (DBusAddressEntry *entry, connection = _dbus_connection_new_for_transport (transport); _dbus_transport_unref (transport); - + if (connection == NULL) { _DBUS_SET_OOM (error); @@ -1831,12 +1831,12 @@ _dbus_connection_open_internal (const char *address, _dbus_verbose ("opening %s connection to: %s\n", shared ? "shared" : "private", address); - + if (!dbus_parse_address (address, &entries, &len, error)) return NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + connection = NULL; for (i = 0; i < len; i++) @@ -1855,14 +1855,14 @@ _dbus_connection_open_internal (const char *address, if (connection != NULL && shared) { const char *guid; - + connection->shareable = TRUE; - + /* guid may be NULL */ guid = dbus_address_entry_get_value (entries[i], "guid"); - + CONNECTION_LOCK (connection); - + if (!connection_record_shared_unlocked (connection, guid)) { _DBUS_SET_OOM (&tmp_error); @@ -1874,21 +1874,21 @@ _dbus_connection_open_internal (const char *address, CONNECTION_UNLOCK (connection); } } - + if (connection) break; _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); - + if (i == 0) dbus_move_error (&tmp_error, &first_error); else dbus_error_free (&tmp_error); } - + _DBUS_ASSERT_ERROR_IS_CLEAR (error); _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); - + if (connection == NULL) { _DBUS_ASSERT_ERROR_IS_SET (&first_error); @@ -1896,7 +1896,7 @@ _dbus_connection_open_internal (const char *address, } else dbus_error_free (&first_error); - + dbus_address_entries_free (entries); return connection; } @@ -1906,7 +1906,7 @@ _dbus_connection_open_internal (const char *address, * only be used on private connections. Should only be called by the * dbus code that owns the connection - an owner must be known, * the open/close state is like malloc/free, not like ref/unref. - * + * * @param connection the connection */ void @@ -1925,9 +1925,9 @@ _dbus_connection_preallocate_send_unlocked (DBusConnection *connection) DBusPreallocatedSend *preallocated; HAVE_LOCK_CHECK (connection); - + _dbus_assert (connection != NULL); - + preallocated = dbus_new (DBusPreallocatedSend, 1); if (preallocated == NULL) return NULL; @@ -1944,7 +1944,7 @@ _dbus_connection_preallocate_send_unlocked (DBusConnection *connection) if (preallocated->queue_link == NULL) goto failed_0; } - + if (connection->link_cache != NULL) { preallocated->counter_link = @@ -1961,14 +1961,14 @@ _dbus_connection_preallocate_send_unlocked (DBusConnection *connection) _dbus_counter_ref (preallocated->counter_link->data); preallocated->connection = connection; - + return preallocated; - + failed_1: _dbus_list_free_link (preallocated->queue_link); failed_0: dbus_free (preallocated); - + return NULL; } @@ -1990,9 +1990,9 @@ _dbus_connection_send_preallocated_unlocked_no_update (DBusConnection *con dbus_free (preallocated); preallocated = NULL; - + dbus_message_ref (message); - + connection->n_outgoing += 1; _dbus_verbose ("Message %p (%s %s %s %s '%s') for %s added to outgoing queue %p, %d pending to send\n", @@ -2029,7 +2029,7 @@ _dbus_connection_send_preallocated_unlocked_no_update (DBusConnection *con _dbus_verbose ("Message %p serial is %u\n", message, dbus_message_get_serial (message)); - + dbus_message_lock (message); /* Now we need to run an iteration to hopefully just write the messages @@ -2054,7 +2054,7 @@ _dbus_connection_send_preallocated_and_unlock (DBusConnection *connection, DBusDispatchStatus status; HAVE_LOCK_CHECK (connection); - + _dbus_connection_send_preallocated_unlocked_no_update (connection, preallocated, message, client_serial); @@ -2084,7 +2084,7 @@ _dbus_connection_send_and_unlock (DBusConnection *connection, _dbus_assert (connection != NULL); _dbus_assert (message != NULL); - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); if (preallocated == NULL) { @@ -2120,14 +2120,14 @@ _dbus_connection_send_and_unlock (DBusConnection *connection, * * If we didn't atomically check the refcount and close with the lock held * though, we could screw this up. - * + * * @param connection the connection */ void _dbus_connection_close_if_only_one_ref (DBusConnection *connection) { CONNECTION_LOCK (connection); - + _dbus_assert (connection->refcount.value > 0); if (connection->refcount.value == 1) @@ -2160,8 +2160,8 @@ _dbus_memory_pause_based_on_timeout (int timeout_milliseconds) } static DBusMessage * -generate_local_error_message (dbus_uint32_t serial, - char *error_name, +generate_local_error_message (dbus_uint32_t serial, + char *error_name, char *error_msg) { DBusMessage *message; @@ -2173,10 +2173,10 @@ generate_local_error_message (dbus_uint32_t serial, { dbus_message_unref (message); message = NULL; - goto out; + goto out; } - dbus_message_set_no_reply (message, TRUE); + dbus_message_set_no_reply (message, TRUE); if (!dbus_message_set_reply_serial (message, serial)) @@ -2242,7 +2242,7 @@ check_for_reply_unlocked (DBusConnection *connection, DBusList *link; HAVE_LOCK_CHECK (connection); - + link = _dbus_list_get_first_link (&connection->incoming_messages); while (link != NULL) @@ -2268,25 +2268,25 @@ connection_timeout_and_complete_all_pending_calls_unlocked (DBusConnection *conn * dropping the lock for each item. So we restart the * iter each time as we drain the hash table. */ - + while (_dbus_hash_table_get_n_entries (connection->pending_replies) > 0) { DBusPendingCall *pending; DBusHashIter iter; - + _dbus_hash_iter_init (connection->pending_replies, &iter); _dbus_hash_iter_next (&iter); - + pending = _dbus_hash_iter_get_value (&iter); _dbus_pending_call_ref_unlocked (pending); - - _dbus_pending_call_queue_timeout_error_unlocked (pending, + + _dbus_pending_call_queue_timeout_error_unlocked (pending, connection); if (_dbus_pending_call_is_timeout_added_unlocked (pending)) _dbus_connection_remove_timeout_unlocked (connection, _dbus_pending_call_get_timeout_unlocked (pending)); - _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); + _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); _dbus_hash_iter_remove_entry (&iter); _dbus_pending_call_unref_and_unlock (pending); @@ -2303,7 +2303,7 @@ complete_pending_call_and_unlock (DBusConnection *connection, _dbus_pending_call_set_reply_unlocked (pending, message); _dbus_pending_call_ref_unlocked (pending); /* in case there's no app with a ref held */ _dbus_connection_detach_pending_call_and_unlock (connection, pending); - + /* Must be called unlocked since it invokes app callback */ _dbus_pending_call_complete (pending); dbus_pending_call_unref (pending); @@ -2316,7 +2316,7 @@ check_for_reply_and_update_dispatch_unlocked (DBusConnection *connection, DBusMessage *reply; DBusDispatchStatus status; - reply = check_for_reply_unlocked (connection, + reply = check_for_reply_unlocked (connection, _dbus_pending_call_get_reply_serial_unlocked (pending)); if (reply != NULL) { @@ -2346,7 +2346,7 @@ check_for_reply_and_update_dispatch_unlocked (DBusConnection *connection, * filter callbacks. * * Returns immediately if pending call already got a reply. - * + * * @todo could use performance improvements (it keeps scanning * the whole message queue for example) * @@ -2371,7 +2371,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) dbus_pending_call_ref (pending); /* necessary because the call could be canceled */ connection = _dbus_pending_call_get_connection_and_lock (pending); - + /* Flush message queue - note, can affect dispatch status */ _dbus_connection_flush_unlocked (connection); @@ -2415,9 +2415,9 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) recheck_status: _dbus_verbose ("top of recheck\n"); - + HAVE_LOCK_CHECK (connection); - + /* queue messages and get status */ status = _dbus_connection_get_dispatch_status_unlocked (connection); @@ -2432,24 +2432,24 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) dbus_pending_call_unref (pending); return; } - + if (status == DBUS_DISPATCH_DATA_REMAINS) { if (check_for_reply_and_update_dispatch_unlocked (connection, pending)) return; } - + _dbus_get_current_time (&tv_sec, &tv_usec); elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 + (tv_usec - start_tv_usec) / 1000; - + if (!_dbus_connection_get_is_connected_unlocked (connection)) { DBusMessage *error_msg; error_msg = generate_local_error_message (client_serial, - DBUS_ERROR_DISCONNECTED, - "Connection was disconnected before a reply was received"); + DBUS_ERROR_DISCONNECTED, + "Connection was disconnected before a reply was received"); /* on OOM error_msg is set to NULL */ complete_pending_call_and_unlock (connection, pending, error_msg); @@ -2471,7 +2471,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); } else - { + { /* block again, we don't have the reply buffered yet. */ _dbus_connection_do_iteration_unlocked (connection, pending, @@ -2487,7 +2487,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) else if (elapsed_milliseconds < timeout_milliseconds) { _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds - elapsed_milliseconds); - + if (status == DBUS_DISPATCH_NEED_MEMORY) { /* Try sleeping a bit, as we aren't sure we need to block for reading, @@ -2499,7 +2499,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); } else - { + { /* block again, we don't have the reply buffered yet. */ _dbus_connection_do_iteration_unlocked (connection, NULL, @@ -2515,7 +2515,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) elapsed_milliseconds); _dbus_assert (!_dbus_pending_call_get_completed_unlocked (pending)); - + /* unlock and call user code */ complete_pending_call_and_unlock (connection, pending, NULL); @@ -2557,7 +2557,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) * unless you have good reason; connections are expensive enough * that it's wasteful to create lots of connections to the same * server. - * + * * @param address the address. * @param error address where an error can be returned. * @returns new connection, or #NULL on failure. @@ -2591,7 +2591,7 @@ dbus_connection_open (const char *address, * When you are done with this connection, you must * dbus_connection_close() to disconnect it, * and dbus_connection_unref() to free the connection object. - * + * * (The dbus_connection_close() can be skipped if the * connection is already known to be disconnected, for example * if you are inside a handler for the Disconnected signal.) @@ -2632,7 +2632,7 @@ dbus_connection_ref (DBusConnection *connection) { _dbus_return_val_if_fail (connection != NULL, NULL); _dbus_return_val_if_fail (connection->generation == _dbus_current_generation, NULL); - + /* The connection lock is better than the global * lock in the atomic increment fallback * @@ -2641,7 +2641,7 @@ dbus_connection_ref (DBusConnection *connection) * the mess with set_timeout_functions()/set_watch_functions() * calling out to the app without dropping locks) */ - + #if 1 _dbus_atomic_inc (&connection->refcount); #else @@ -2678,30 +2678,30 @@ _dbus_connection_last_unref (DBusConnection *connection) DBusList *link; _dbus_verbose ("Finalizing connection %p\n", connection); - + _dbus_assert (connection->refcount.value == 0); - + /* You have to disconnect the connection before unref:ing it. Otherwise * you won't get the disconnected message. */ _dbus_assert (!_dbus_transport_get_is_connected (connection->transport)); _dbus_assert (connection->server_guid == NULL); - + /* ---- We're going to call various application callbacks here, hope it doesn't break anything... */ _dbus_object_tree_free_all_unlocked (connection->objects); - + dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); dbus_connection_set_wakeup_main_function (connection, NULL, NULL, NULL); dbus_connection_set_unix_user_function (connection, NULL, NULL, NULL); - + _dbus_watch_list_free (connection->watches); connection->watches = NULL; - + _dbus_timeout_list_free (connection->timeouts); connection->timeouts = NULL; _dbus_data_slot_list_free (&connection->slot_list); - + link = _dbus_list_get_first_link (&connection->filter_list); while (link != NULL) { @@ -2711,25 +2711,25 @@ _dbus_connection_last_unref (DBusConnection *connection) filter->function = NULL; _dbus_message_filter_unref (filter); /* calls app callback */ link->data = NULL; - + link = next; } _dbus_list_clear (&connection->filter_list); - + /* ---- Done with stuff that invokes application callbacks */ - _dbus_object_tree_unref (connection->objects); + _dbus_object_tree_unref (connection->objects); _dbus_hash_table_unref (connection->pending_replies); connection->pending_replies = NULL; - + _dbus_list_clear (&connection->filter_list); - + _dbus_list_foreach (&connection->outgoing_messages, free_outgoing_message, connection); _dbus_list_clear (&connection->outgoing_messages); - + _dbus_list_foreach (&connection->incoming_messages, (DBusForeachFunction) dbus_message_unref, NULL); @@ -2747,7 +2747,7 @@ _dbus_connection_last_unref (DBusConnection *connection) } _dbus_list_clear (&connection->link_cache); - + _dbus_condvar_free_at_location (&connection->dispatch_cond); _dbus_condvar_free_at_location (&connection->io_path_cond); @@ -2757,7 +2757,7 @@ _dbus_connection_last_unref (DBusConnection *connection) _dbus_mutex_free_at_location (&connection->slot_mutex); _dbus_mutex_free_at_location (&connection->mutex); - + dbus_free (connection); } @@ -2787,7 +2787,7 @@ dbus_connection_unref (DBusConnection *connection) _dbus_return_if_fail (connection != NULL); _dbus_return_if_fail (connection->generation == _dbus_current_generation); - + /* The connection lock is better than the global * lock in the atomic increment fallback * @@ -2796,12 +2796,12 @@ dbus_connection_unref (DBusConnection *connection) * the mess with set_timeout_functions()/set_watch_functions() * calling out to the app without dropping locks) */ - + #if 1 last_unref = (_dbus_atomic_dec (&connection->refcount) == 1); #else CONNECTION_LOCK (connection); - + _dbus_assert (connection->refcount.value > 0); connection->refcount.value -= 1; @@ -2810,10 +2810,10 @@ dbus_connection_unref (DBusConnection *connection) #if 0 printf ("unref() connection %p count = %d\n", connection, connection->refcount.value); #endif - + CONNECTION_UNLOCK (connection); #endif - + if (last_unref) { #ifndef DBUS_DISABLE_CHECKS @@ -2821,7 +2821,7 @@ dbus_connection_unref (DBusConnection *connection) { _dbus_warn_check_failed ("The last reference on a connection was dropped without closing the connection. This is a bug in an application. See dbus_connection_unref() documentation for details.\n%s", connection->shareable ? - "Most likely, the application called unref() too many times and removed a reference belonging to libdbus, since this is a shared connection.\n" : + "Most likely, the application called unref() too many times and removed a reference belonging to libdbus, since this is a shared connection.\n" : "Most likely, the application was supposed to call dbus_connection_close(), since this is a private connection.\n"); return; } @@ -2835,7 +2835,7 @@ dbus_connection_unref (DBusConnection *connection) * and in that case this function never runs. So this function must * not do anything more than disconnect the transport and update the * dispatch status. - * + * * If the transport self-disconnects, then we assume someone will * dispatch the connection to cause the dispatch status update. */ @@ -2845,7 +2845,7 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) DBusDispatchStatus status; HAVE_LOCK_CHECK (connection); - + _dbus_verbose ("Disconnecting %p\n", connection); /* We need to ref because update_dispatch_status_and_unlock will unref @@ -2853,7 +2853,7 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) * refcount holder. */ _dbus_connection_ref_unlocked (connection); - + _dbus_transport_disconnect (connection->transport); /* This has the side effect of queuing the disconnect message link @@ -2881,7 +2881,7 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) * * Attempts to send messages after closing a connection are safe, but will result in * error replies generated locally in libdbus. - * + * * This function does not affect the connection's reference count. It's * safe to close a connection more than once; all calls after the * first do nothing. It's impossible to "reopen" a connection, a @@ -2891,8 +2891,8 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) * message it generates needs to be dispatched. * * If a connection is dropped by the remote application, it will - * close itself. - * + * close itself. + * * You must close a connection prior to releasing the last reference to * the connection. If you dbus_connection_unref() for the last time * without closing the connection, the results are undefined; it @@ -2933,7 +2933,7 @@ dbus_connection_close (DBusConnection *connection) return; } #endif - + _dbus_connection_close_possibly_shared_and_unlock (connection); } @@ -2949,7 +2949,7 @@ _dbus_connection_get_is_connected_unlocked (DBusConnection *connection) * become disconnected when the remote application closes its end, or * exits; a connection may also be disconnected with * dbus_connection_close(). - * + * * There are not separate states for "closed" and "disconnected," the two * terms are synonymous. This function should really be called * get_is_open() but for historical reasons is not. @@ -2963,11 +2963,11 @@ dbus_connection_get_is_connected (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); res = _dbus_connection_get_is_connected_unlocked (connection); CONNECTION_UNLOCK (connection); - + return res; } @@ -2985,11 +2985,11 @@ dbus_connection_get_is_authenticated (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_is_authenticated (connection->transport); CONNECTION_UNLOCK (connection); - + return res; } @@ -3009,9 +3009,9 @@ dbus_connection_get_is_authenticated (DBusConnection *connection) * dbus_server_set_auth_mechanisms() to remove the mechanisms that * allow proving user identity (i.e. only allow the ANONYMOUS * mechanism). - * + * * @param connection the connection - * @returns #TRUE if not authenticated or authenticated as anonymous + * @returns #TRUE if not authenticated or authenticated as anonymous */ dbus_bool_t dbus_connection_get_is_anonymous (DBusConnection *connection) @@ -3019,11 +3019,11 @@ dbus_connection_get_is_anonymous (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_is_anonymous (connection->transport); CONNECTION_UNLOCK (connection); - + return res; } @@ -3032,7 +3032,7 @@ dbus_connection_get_is_anonymous (DBusConnection *connection) * connection is on the client side. If the connection is on the * server side, this will always return #NULL - use dbus_server_get_id() * to get the ID of your own server, if you are the server side. - * + * * If a client-side connection is not authenticated yet, the ID may be * available if it was included in the server address, but may not be * available. The only way to be sure the server ID is available @@ -3051,7 +3051,7 @@ dbus_connection_get_is_anonymous (DBusConnection *connection) * get the machine you are on. There isn't a convenience wrapper, but * you can invoke org.freedesktop.DBus.Peer.GetMachineId on any peer * to get the machine ID on the other end. - * + * * The D-Bus specification describes the server ID and other IDs in a * bit more detail. * @@ -3141,7 +3141,7 @@ dbus_connection_set_exit_on_disconnect (DBusConnection *connection, } /** - * Preallocates resources needed to send a message, allowing the message + * Preallocates resources needed to send a message, allowing the message * to be sent without the possibility of memory allocation failure. * Allows apps to create a future guarantee that they can send * a message regardless of memory shortages. @@ -3157,7 +3157,7 @@ dbus_connection_preallocate_send (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, NULL); CONNECTION_LOCK (connection); - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); @@ -3180,7 +3180,7 @@ dbus_connection_free_preallocated_send (DBusConnection *connection, DBusPreallocatedSend *preallocated) { _dbus_return_if_fail (connection != NULL); - _dbus_return_if_fail (preallocated != NULL); + _dbus_return_if_fail (preallocated != NULL); _dbus_return_if_fail (connection == preallocated->connection); _dbus_list_free_link (preallocated->queue_link); @@ -3247,7 +3247,7 @@ _dbus_connection_send_unlocked_no_update (DBusConnection *connection, _dbus_assert (connection != NULL); _dbus_assert (message != NULL); - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); if (preallocated == NULL) return FALSE; @@ -3263,15 +3263,15 @@ _dbus_connection_send_unlocked_no_update (DBusConnection *connection, * Adds a message to the outgoing message queue. Does not block to * write the message to the network; that happens asynchronously. To * force the message to be written, call dbus_connection_flush() however - * it is not necessary to call dbus_connection_flush() by hand; the - * message will be sent the next time the main loop is run. + * it is not necessary to call dbus_connection_flush() by hand; the + * message will be sent the next time the main loop is run. * dbus_connection_flush() should only be used, for example, if * the application was expected to exit before running the main loop. * * Because this only queues the message, the only reason it can * fail is lack of memory. Even if the connection is disconnected, - * no error will be returned. If the function fails due to lack of memory, - * it returns #FALSE. The function will never fail for other reasons; even + * no error will be returned. If the function fails due to lack of memory, + * it returns #FALSE. The function will never fail for other reasons; even * if the connection is disconnected, you can queue an outgoing message, * though obviously it won't be sent. * @@ -3280,7 +3280,7 @@ _dbus_connection_send_unlocked_no_update (DBusConnection *connection, * * dbus_message_unref() can be called as soon as this method returns * as the message queue will hold its own ref until the message is sent. - * + * * @param connection the connection. * @param message the message to write. * @param serial return location for message serial, or #NULL if you don't care @@ -3324,7 +3324,7 @@ reply_handler_timeout (void *data) connection = _dbus_pending_call_get_connection_and_lock (pending); - _dbus_pending_call_queue_timeout_error_unlocked (pending, + _dbus_pending_call_queue_timeout_error_unlocked (pending, connection); _dbus_connection_remove_timeout_unlocked (connection, _dbus_pending_call_get_timeout_unlocked (pending)); @@ -3335,7 +3335,7 @@ reply_handler_timeout (void *data) /* Unlocks, and calls out to user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + return TRUE; } @@ -3353,7 +3353,7 @@ reply_handler_timeout (void *data) * * A #DBusPendingCall will always see exactly one reply message, * unless it's cancelled with dbus_pending_call_cancel(). - * + * * If #NULL is passed for the pending_return, the #DBusPendingCall * will still be generated internally, and used to track * the message reply timeout. This means a timeout error will @@ -3439,7 +3439,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, if (!_dbus_pending_call_set_timeout_error_unlocked (pending, message, serial)) goto error; - + /* Insert the serial in the pending replies hash; * hash takes a refcount on DBusPendingCall. * Also, add the timeout. @@ -3447,7 +3447,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, if (!_dbus_connection_attach_pending_call_unlocked (connection, pending)) goto error; - + if (!_dbus_connection_send_unlocked_no_update (connection, message, NULL)) { _dbus_connection_detach_pending_call_and_unlock (connection, @@ -3472,7 +3472,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, if (pending_return == NULL) dbus_pending_call_unref (pending); - + return TRUE; error: @@ -3488,7 +3488,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, * i.e. messages other than the reply are queued up but not * processed. This function is used to invoke method calls on a * remote object. - * + * * If a normal reply is received, it is returned, and removed from the * incoming message queue. If it is not received, #NULL is returned * and the error is set to #DBUS_ERROR_NO_REPLY. If an error reply is @@ -3552,7 +3552,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection, dbus_set_error (error, DBUS_ERROR_DISCONNECTED, "Connection is closed"); return NULL; } - + dbus_pending_call_block (pending); reply = dbus_pending_call_steal_reply (pending); @@ -3562,7 +3562,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection, * always fill this in. */ _dbus_assert (reply != NULL); - + if (dbus_set_error_from_message (error, reply)) { dbus_message_unref (reply); @@ -3577,7 +3577,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection, * Assumes connection lock already held. * * If you call this, you MUST call update_dispatch_status afterword... - * + * * @param connection the connection. */ static DBusDispatchStatus @@ -3591,7 +3591,7 @@ _dbus_connection_flush_unlocked (DBusConnection *connection) DBusDispatchStatus status; HAVE_LOCK_CHECK (connection); - + while (connection->n_outgoing > 0 && _dbus_connection_get_is_connected_unlocked (connection)) { @@ -3629,11 +3629,11 @@ dbus_connection_flush (DBusConnection *connection) DBusDispatchStatus status; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); status = _dbus_connection_flush_unlocked (connection); - + HAVE_LOCK_CHECK (connection); /* Unlocks and calls out to user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); @@ -3645,7 +3645,7 @@ dbus_connection_flush (DBusConnection *connection) * This function implements dbus_connection_read_write_dispatch() and * dbus_connection_read_write() (they pass a different value for the * dispatch parameter). - * + * * @param connection the connection * @param timeout_milliseconds max time to block or -1 for infinite * @param dispatch dispatch new messages or leave them on the incoming queue @@ -3653,14 +3653,14 @@ dbus_connection_flush (DBusConnection *connection) */ static dbus_bool_t _dbus_connection_read_write_dispatch (DBusConnection *connection, - int timeout_milliseconds, + int timeout_milliseconds, dbus_bool_t dispatch) { DBusDispatchStatus dstatus; dbus_bool_t progress_possible; /* Need to grab a ref here in case we're a private connection and - * the user drops the last ref in a handler we call; see bug + * the user drops the last ref in a handler we call; see bug * https://bugs.freedesktop.org/show_bug.cgi?id=15635 */ dbus_connection_ref (connection); @@ -3692,7 +3692,7 @@ _dbus_connection_read_write_dispatch (DBusConnection *connection, timeout_milliseconds); } } - + HAVE_LOCK_CHECK (connection); /* If we can dispatch, we can make progress until the Disconnected message * has been processed; if we can only read/write, we can make progress @@ -3716,16 +3716,16 @@ _dbus_connection_read_write_dispatch (DBusConnection *connection, * This function is intended for use with applications that don't want * to write a main loop and deal with #DBusWatch and #DBusTimeout. An * example usage would be: - * + * * @code * while (dbus_connection_read_write_dispatch (connection, -1)) * ; // empty loop body * @endcode - * + * * In this usage you would normally have set up a filter function to look * at each message as it is dispatched. The loop terminates when the last * message from the connection (the disconnected signal) is processed. - * + * * If there are messages to dispatch, this function will * dbus_connection_dispatch() once, and return. If there are no * messages to dispatch, this function will block until it can read or @@ -3755,11 +3755,11 @@ dbus_connection_read_write_dispatch (DBusConnection *connection, return _dbus_connection_read_write_dispatch(connection, timeout_milliseconds, TRUE); } -/** +/** * This function is intended for use with applications that don't want to * write a main loop and deal with #DBusWatch and #DBusTimeout. See also * dbus_connection_read_write_dispatch(). - * + * * As long as the connection is open, this function will block until it can * read or write, then read or write, then return #TRUE. * @@ -3773,15 +3773,15 @@ dbus_connection_read_write_dispatch (DBusConnection *connection, * processed. dbus_connection_read_write_dispatch() dispatches * incoming messages for you; with dbus_connection_read_write() you * have to arrange to drain the incoming queue yourself. - * - * @param connection the connection - * @param timeout_milliseconds max time to block or -1 for infinite + * + * @param connection the connection + * @param timeout_milliseconds max time to block or -1 for infinite * @returns #TRUE if still connected */ -dbus_bool_t -dbus_connection_read_write (DBusConnection *connection, - int timeout_milliseconds) -{ +dbus_bool_t +dbus_connection_read_write (DBusConnection *connection, + int timeout_milliseconds) +{ _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (timeout_milliseconds >= 0 || timeout_milliseconds == -1, FALSE); return _dbus_connection_read_write_dispatch(connection, timeout_milliseconds, FALSE); @@ -3811,7 +3811,7 @@ check_disconnected_message_arrived_unlocked (DBusConnection *connection, /** * Returns the first-received message from the incoming message queue, * leaving it in the queue. If the queue is empty, returns #NULL. - * + * * The caller does not own a reference to the returned message, and * must either return it using dbus_connection_return_message() or * keep it after calling dbus_connection_steal_borrowed_message(). No @@ -3836,14 +3836,14 @@ dbus_connection_borrow_message (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, NULL); _dbus_verbose ("start\n"); - + /* this is called for the side effect that it queues * up any messages from the transport */ status = dbus_connection_get_dispatch_status (connection); if (status != DBUS_DISPATCH_DATA_REMAINS) return NULL; - + CONNECTION_LOCK (connection); _dbus_connection_acquire_dispatch (connection); @@ -3852,11 +3852,11 @@ dbus_connection_borrow_message (DBusConnection *connection) _dbus_assert (connection->message_borrowed == NULL); connection->message_borrowed = _dbus_list_get_first (&connection->incoming_messages); - + message = connection->message_borrowed; check_disconnected_message_arrived_unlocked (connection, message); - + /* Note that we KEEP the dispatch lock until the message is returned */ if (message == NULL) _dbus_connection_release_dispatch (connection); @@ -3864,7 +3864,7 @@ dbus_connection_borrow_message (DBusConnection *connection) CONNECTION_UNLOCK (connection); /* We don't update dispatch status until it's returned or stolen */ - + return message; } @@ -3881,19 +3881,19 @@ dbus_connection_return_message (DBusConnection *connection, DBusMessage *message) { DBusDispatchStatus status; - + _dbus_return_if_fail (connection != NULL); _dbus_return_if_fail (message != NULL); _dbus_return_if_fail (message == connection->message_borrowed); _dbus_return_if_fail (connection->dispatch_acquired); - + CONNECTION_LOCK (connection); - + _dbus_assert (message == connection->message_borrowed); - + connection->message_borrowed = NULL; - _dbus_connection_release_dispatch (connection); + _dbus_connection_release_dispatch (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); _dbus_connection_update_dispatch_status_and_unlock (connection, status); @@ -3919,19 +3919,19 @@ dbus_connection_steal_borrowed_message (DBusConnection *connection, _dbus_return_if_fail (message != NULL); _dbus_return_if_fail (message == connection->message_borrowed); _dbus_return_if_fail (connection->dispatch_acquired); - + CONNECTION_LOCK (connection); - + _dbus_assert (message == connection->message_borrowed); pop_message = _dbus_list_pop_first (&connection->incoming_messages); _dbus_assert (message == pop_message); - + connection->n_incoming -= 1; - + _dbus_verbose ("Incoming message %p stolen from queue, %d incoming\n", message, connection->n_incoming); - + connection->message_borrowed = NULL; _dbus_connection_release_dispatch (connection); @@ -3947,9 +3947,9 @@ static DBusList* _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + _dbus_assert (connection->message_borrowed == NULL); - + if (connection->n_incoming > 0) { DBusList *link; @@ -3973,7 +3973,7 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) connection, connection->n_incoming); check_disconnected_message_arrived_unlocked (connection, link->data); - + return link; } else @@ -3989,17 +3989,17 @@ _dbus_connection_pop_message_unlocked (DBusConnection *connection) DBusList *link; HAVE_LOCK_CHECK (connection); - + link = _dbus_connection_pop_message_link_unlocked (connection); if (link != NULL) { DBusMessage *message; - + message = link->data; - + _dbus_list_free_link (link); - + return message; } else @@ -4011,7 +4011,7 @@ _dbus_connection_putback_message_link_unlocked (DBusConnection *connection, DBusList *message_link) { HAVE_LOCK_CHECK (connection); - + _dbus_assert (message_link != NULL); /* You can't borrow a message while a link is outstanding */ _dbus_assert (connection->message_borrowed == NULL); @@ -4050,7 +4050,7 @@ _dbus_connection_putback_message_link_unlocked (DBusConnection *connection, * queue, so dbus_connection_dispatch(), dbus_connection_pop_message(), * dbus_connection_borrow_message(), etc. will all block while one of the others * in the group is running. - * + * * @param connection the connection. * @returns next message in the incoming queue. */ @@ -4061,27 +4061,27 @@ dbus_connection_pop_message (DBusConnection *connection) DBusDispatchStatus status; _dbus_verbose ("start\n"); - + /* this is called for the side effect that it queues * up any messages from the transport */ status = dbus_connection_get_dispatch_status (connection); if (status != DBUS_DISPATCH_DATA_REMAINS) return NULL; - + CONNECTION_LOCK (connection); _dbus_connection_acquire_dispatch (connection); HAVE_LOCK_CHECK (connection); - + message = _dbus_connection_pop_message_unlocked (connection); - _dbus_verbose ("Returning popped message %p\n", message); + _dbus_verbose ("Returning popped message %p\n", message); _dbus_connection_release_dispatch (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + return message; } @@ -4099,24 +4099,24 @@ _dbus_connection_acquire_dispatch (DBusConnection *connection) _dbus_connection_ref_unlocked (connection); CONNECTION_UNLOCK (connection); - + _dbus_verbose ("locking dispatch_mutex\n"); _dbus_mutex_lock (connection->dispatch_mutex); while (connection->dispatch_acquired) { _dbus_verbose ("waiting for dispatch to be acquirable\n"); - _dbus_condvar_wait (connection->dispatch_cond, + _dbus_condvar_wait (connection->dispatch_cond, connection->dispatch_mutex); } - + _dbus_assert (!connection->dispatch_acquired); connection->dispatch_acquired = TRUE; _dbus_verbose ("unlocking dispatch_mutex\n"); _dbus_mutex_unlock (connection->dispatch_mutex); - + CONNECTION_LOCK (connection); _dbus_connection_unref_unlocked (connection); } @@ -4132,10 +4132,10 @@ static void _dbus_connection_release_dispatch (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + _dbus_verbose ("locking dispatch_mutex\n"); _dbus_mutex_lock (connection->dispatch_mutex); - + _dbus_assert (connection->dispatch_acquired); connection->dispatch_acquired = FALSE; @@ -4175,15 +4175,15 @@ notify_disconnected_unlocked (DBusConnection *connection) if (connection->n_outgoing > 0) { DBusList *link; - + _dbus_verbose ("Dropping %d outgoing messages since we're disconnected\n", connection->n_outgoing); - + while ((link = _dbus_list_get_last_link (&connection->outgoing_messages))) { _dbus_connection_message_sent (connection, link->data); } - } + } } /* Note this may be called multiple times since we don't track whether we already did it */ @@ -4191,16 +4191,16 @@ static DBusDispatchStatus notify_disconnected_and_dispatch_complete_unlocked (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + if (connection->disconnect_message_link != NULL) { _dbus_verbose ("Sending disconnect message\n"); - + /* If we have pending calls, queue their timeouts - we want the Disconnected * to be the last message, after these timeouts. */ connection_timeout_and_complete_all_pending_calls_unlocked (connection); - + /* We haven't sent the disconnect message already, * and all real messages have been queued up. */ @@ -4218,7 +4218,7 @@ static DBusDispatchStatus _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + if (connection->n_incoming > 0) return DBUS_DISPATCH_DATA_REMAINS; else if (!_dbus_transport_queue_messages (connection->transport)) @@ -4227,13 +4227,13 @@ _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection) { DBusDispatchStatus status; dbus_bool_t is_connected; - + status = _dbus_transport_get_dispatch_status (connection->transport); is_connected = _dbus_transport_get_is_connected (connection->transport); _dbus_verbose ("dispatch status = %s is_connected = %d\n", DISPATCH_STATUS_NAME (status), is_connected); - + if (!is_connected) { /* It's possible this would be better done by having an explicit @@ -4252,7 +4252,7 @@ _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection) if (status == DBUS_DISPATCH_COMPLETE) status = notify_disconnected_and_dispatch_complete_unlocked (connection); } - + if (status != DBUS_DISPATCH_COMPLETE) return status; else if (connection->n_incoming > 0) @@ -4285,7 +4285,7 @@ _dbus_connection_update_dispatch_status_and_unlock (DBusConnection *connectio !connection->disconnected_message_processed) { connection->disconnected_message_processed = TRUE; - + /* this does an unref, but we have a ref * so we should not run the finalizer here * inside the lock. @@ -4294,25 +4294,25 @@ _dbus_connection_update_dispatch_status_and_unlock (DBusConnection *connectio if (connection->exit_on_disconnect) { - CONNECTION_UNLOCK (connection); - + CONNECTION_UNLOCK (connection); + _dbus_verbose ("Exiting on Disconnected signal\n"); _dbus_exit (1); _dbus_assert_not_reached ("Call to exit() returned"); } } - + /* We drop the lock */ CONNECTION_UNLOCK (connection); - + if (changed && function) { _dbus_verbose ("Notifying of change to dispatch status of %p now %d (%s)\n", connection, new_status, DISPATCH_STATUS_NAME (new_status)); - (* function) (connection, new_status, data); + (* function) (connection, new_status, data); } - + dbus_connection_unref (connection); } @@ -4337,7 +4337,7 @@ _dbus_connection_update_dispatch_status_and_unlock (DBusConnection *connectio * In particular this happens on initial connection, because all sorts * of authentication protocol stuff has to be parsed before the * first message arrives. - * + * * @param connection the connection. * @returns current dispatch status */ @@ -4349,11 +4349,11 @@ dbus_connection_get_dispatch_status (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, DBUS_DISPATCH_COMPLETE); _dbus_verbose ("start\n"); - + CONNECTION_LOCK (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); - + CONNECTION_UNLOCK (connection); return status; @@ -4377,18 +4377,18 @@ _dbus_connection_peer_filter_unlocked_no_update (DBusConnection *connection, { DBusMessage *ret; dbus_bool_t sent; - + ret = dbus_message_new_method_return (message); if (ret == NULL) return DBUS_HANDLER_RESULT_NEED_MEMORY; - + sent = _dbus_connection_send_unlocked_no_update (connection, ret, NULL); dbus_message_unref (ret); if (!sent) return DBUS_HANDLER_RESULT_NEED_MEMORY; - + return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_is_method_call (message, @@ -4398,7 +4398,7 @@ _dbus_connection_peer_filter_unlocked_no_update (DBusConnection *connection, DBusMessage *ret; dbus_bool_t sent; DBusString uuid; - + ret = dbus_message_new_method_return (message); if (ret == NULL) return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -4416,12 +4416,12 @@ _dbus_connection_peer_filter_unlocked_no_update (DBusConnection *connection, } } _dbus_string_free (&uuid); - + dbus_message_unref (ret); if (!sent) return DBUS_HANDLER_RESULT_NEED_MEMORY; - + return DBUS_HANDLER_RESULT_HANDLED; } else if (dbus_message_has_interface (message, DBUS_INTERFACE_PEER)) @@ -4430,23 +4430,23 @@ _dbus_connection_peer_filter_unlocked_no_update (DBusConnection *connection, * could start extending the interface and when we added extensions * here to DBusConnection we'd break those apps. */ - + DBusMessage *ret; dbus_bool_t sent; - + ret = dbus_message_new_error (message, DBUS_ERROR_UNKNOWN_METHOD, "Unknown method invoked on org.freedesktop.DBus.Peer interface"); if (ret == NULL) return DBUS_HANDLER_RESULT_NEED_MEMORY; - + sent = _dbus_connection_send_unlocked_no_update (connection, ret, NULL); - + dbus_message_unref (ret); - + if (!sent) return DBUS_HANDLER_RESULT_NEED_MEMORY; - + return DBUS_HANDLER_RESULT_HANDLED; } else @@ -4481,7 +4481,7 @@ _dbus_connection_run_builtin_filters_unlocked_no_update (DBusConnection *connect * The incoming data buffer is filled when the connection reads from * its underlying transport (such as a socket). Reading usually * happens in dbus_watch_handle() or dbus_connection_read_write(). - * + * * If there are complete messages in the incoming queue, * dbus_connection_dispatch() removes one message from the queue and * processes it. Processing has three steps. @@ -4489,7 +4489,7 @@ _dbus_connection_run_builtin_filters_unlocked_no_update (DBusConnection *connect * First, any method replies are passed to #DBusPendingCall or * dbus_connection_send_with_reply_and_block() in order to * complete the pending method call. - * + * * Second, any filters registered with dbus_connection_add_filter() * are run. If any filter returns #DBUS_HANDLER_RESULT_HANDLED * then processing stops after that filter. @@ -4507,9 +4507,9 @@ _dbus_connection_run_builtin_filters_unlocked_no_update (DBusConnection *connect * recursively. If threads have been initialized with a recursive * mutex function, then this will not deadlock; however, it can * certainly confuse your application. - * + * * @todo some FIXME in here about handling DBUS_HANDLER_RESULT_NEED_MEMORY - * + * * @param connection the connection * @returns dispatch status, see dbus_connection_get_dispatch_status() */ @@ -4522,11 +4522,12 @@ dbus_connection_dispatch (DBusConnection *connection) DBusPendingCall *pending; dbus_int32_t reply_serial; DBusDispatchStatus status; + dbus_bool_t found_object; _dbus_return_val_if_fail (connection != NULL, DBUS_DISPATCH_COMPLETE); _dbus_verbose ("\n"); - + CONNECTION_LOCK (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); if (status != DBUS_DISPATCH_DATA_REMAINS) @@ -4535,7 +4536,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_connection_update_dispatch_status_and_unlock (connection, status); return status; } - + /* We need to ref the connection since the callback could potentially * drop the last ref to it */ @@ -4550,15 +4551,15 @@ dbus_connection_dispatch (DBusConnection *connection) /* another thread dispatched our stuff */ _dbus_verbose ("another thread dispatched message (during acquire_dispatch above)\n"); - + _dbus_connection_release_dispatch (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + dbus_connection_unref (connection); - + return status; } @@ -4576,14 +4577,14 @@ dbus_connection_dispatch (DBusConnection *connection) dbus_message_get_signature (message)); result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - + /* Pending call handling must be first, because if you do * dbus_connection_send_with_reply_and_block() or * dbus_pending_call_block() then no handlers/filters will be run on * the reply. We want consistent semantics in the case where we * dbus_connection_dispatch() the reply. */ - + reply_serial = dbus_message_get_reply_serial (message); pending = _dbus_hash_table_lookup_int (connection->pending_replies, reply_serial); @@ -4592,7 +4593,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose ("Dispatching a pending reply\n"); complete_pending_call_and_unlock (connection, pending, message); pending = NULL; /* it's probably unref'd */ - + CONNECTION_LOCK (connection); _dbus_verbose ("pending call completed in dispatch\n"); result = DBUS_HANDLER_RESULT_HANDLED; @@ -4602,12 +4603,12 @@ dbus_connection_dispatch (DBusConnection *connection) result = _dbus_connection_run_builtin_filters_unlocked_no_update (connection, message); if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED) goto out; - + if (!_dbus_list_copy (&connection->filter_list, &filter_list_copy)) { _dbus_connection_release_dispatch (connection); HAVE_LOCK_CHECK (connection); - + _dbus_connection_failed_pop (connection, message_link); /* unlocks and calls user code */ @@ -4617,10 +4618,10 @@ dbus_connection_dispatch (DBusConnection *connection) if (pending) dbus_pending_call_unref (pending); dbus_connection_unref (connection); - + return DBUS_DISPATCH_NEED_MEMORY; } - + _dbus_list_foreach (&filter_list_copy, (DBusForeachFunction)_dbus_message_filter_ref, NULL); @@ -4629,7 +4630,7 @@ dbus_connection_dispatch (DBusConnection *connection) * since we acquired the dispatcher */ CONNECTION_UNLOCK (connection); - + link = _dbus_list_get_first_link (&filter_list_copy); while (link != NULL) { @@ -4656,7 +4657,7 @@ dbus_connection_dispatch (DBusConnection *connection) (DBusForeachFunction)_dbus_message_filter_unref, NULL); _dbus_list_clear (&filter_list_copy); - + CONNECTION_LOCK (connection); if (result == DBUS_HANDLER_RESULT_NEED_MEMORY) @@ -4686,8 +4687,9 @@ dbus_connection_dispatch (DBusConnection *connection) HAVE_LOCK_CHECK (connection); result = _dbus_object_tree_dispatch_and_unlock (connection->objects, - message); - + message, + &found_object); + CONNECTION_LOCK (connection); if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED) @@ -4704,14 +4706,14 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose (" sending error %s\n", DBUS_ERROR_UNKNOWN_METHOD); - + if (!_dbus_string_init (&str)) { result = DBUS_HANDLER_RESULT_NEED_MEMORY; _dbus_verbose ("no memory for error string in dispatch\n"); goto out; } - + if (!_dbus_string_append_printf (&str, "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist\n", dbus_message_get_member (message), @@ -4723,9 +4725,9 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose ("no memory for error string in dispatch\n"); goto out; } - + reply = dbus_message_new_error (message, - DBUS_ERROR_UNKNOWN_METHOD, + found_object ? DBUS_ERROR_UNKNOWN_METHOD : DBUS_ERROR_UNKNOWN_OBJECT, _dbus_string_get_const_data (&str)); _dbus_string_free (&str); @@ -4735,7 +4737,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose ("no memory for error reply in dispatch\n"); goto out; } - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); if (preallocated == NULL) @@ -4750,10 +4752,10 @@ dbus_connection_dispatch (DBusConnection *connection) reply, NULL); dbus_message_unref (reply); - + result = DBUS_HANDLER_RESULT_HANDLED; } - + _dbus_verbose (" done dispatching %p (%s %s %s '%s') on connection %p\n", message, dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_interface (message) ? @@ -4764,12 +4766,12 @@ dbus_connection_dispatch (DBusConnection *connection) "no member", dbus_message_get_signature (message), connection); - + out: if (result == DBUS_HANDLER_RESULT_NEED_MEMORY) { _dbus_verbose ("out of memory\n"); - + /* Put message back, and we'll start over. * Yes this means handlers must be idempotent if they * don't return HANDLED; c'est la vie. @@ -4780,13 +4782,13 @@ dbus_connection_dispatch (DBusConnection *connection) else { _dbus_verbose (" ... done dispatching\n"); - + _dbus_list_free_link (message_link); dbus_message_unref (message); /* don't want the message to count in max message limits * in computing dispatch status below */ } - + _dbus_connection_release_dispatch (connection); HAVE_LOCK_CHECK (connection); @@ -4795,9 +4797,9 @@ dbus_connection_dispatch (DBusConnection *connection) /* unlocks and calls user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + dbus_connection_unref (connection); - + return status; } @@ -4819,7 +4821,7 @@ dbus_connection_dispatch (DBusConnection *connection) * enabling/disabling can be done without memory allocation. The * toggled function may be NULL if a main loop re-queries * dbus_watch_get_enabled() every time anyway. - * + * * The DBusWatch can be queried for the file descriptor to watch using * dbus_watch_get_unix_fd() or dbus_watch_get_socket(), and for the * events to watch for using dbus_watch_get_flags(). The flags @@ -4836,7 +4838,7 @@ dbus_connection_dispatch (DBusConnection *connection) * dbus_watch_handle() cannot be called during the * DBusAddWatchFunction, as the connection will not be ready to handle * that watch yet. - * + * * It is not allowed to reference a DBusWatch after it has been passed * to remove_function. * @@ -4853,7 +4855,7 @@ dbus_connection_dispatch (DBusConnection *connection) * may not invoke any methods on DBusConnection or it will deadlock. * See the comments in the code or http://lists.freedesktop.org/archives/dbus/2007-July/tread.html#8144 * if you encounter this issue and want to attempt writing a patch. - * + * * @param connection the connection. * @param add_function function to begin monitoring a new descriptor. * @param remove_function function to stop monitoring a descriptor. @@ -4873,7 +4875,7 @@ dbus_connection_set_watch_functions (DBusConnection *connection, dbus_bool_t retval; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); retval = _dbus_watch_list_set_functions (connection->watches, @@ -4892,7 +4894,7 @@ dbus_connection_set_watch_functions (DBusConnection *connection, * When using Qt, typically the DBusAddTimeoutFunction would create a * QTimer. When using GLib, the DBusAddTimeoutFunction would call * g_timeout_add. - * + * * The DBusTimeoutToggledFunction notifies the application that the * timeout has been enabled or disabled. Call * dbus_timeout_get_enabled() to check this. A disabled timeout should @@ -4936,7 +4938,7 @@ dbus_connection_set_timeout_functions (DBusConnection *connection, dbus_bool_t retval; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); retval = _dbus_timeout_list_set_functions (connection->timeouts, @@ -4973,7 +4975,7 @@ dbus_connection_set_wakeup_main_function (DBusConnection *connection, DBusFreeFunction old_free_data; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); old_data = connection->wakeup_main_data; old_free_data = connection->free_wakeup_main_data; @@ -4981,7 +4983,7 @@ dbus_connection_set_wakeup_main_function (DBusConnection *connection, connection->wakeup_main_function = wakeup_main_function; connection->wakeup_main_data = data; connection->free_wakeup_main_data = free_data_function; - + CONNECTION_UNLOCK (connection); /* Callback outside the lock */ @@ -5019,7 +5021,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection *connec DBusFreeFunction old_free_data; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); old_data = connection->dispatch_status_data; old_free_data = connection->free_dispatch_status_data; @@ -5027,7 +5029,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection *connec connection->dispatch_status_function = function; connection->dispatch_status_data = data; connection->free_dispatch_status_data = free_data_function; - + CONNECTION_UNLOCK (connection); /* Callback outside the lock */ @@ -5049,7 +5051,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection *connec * * Right now the returned descriptor is always a socket, but * that is not guaranteed. - * + * * @param connection the connection * @param fd return location for the file descriptor. * @returns #TRUE if fd is successfully obtained. @@ -5065,7 +5067,7 @@ dbus_connection_get_unix_fd (DBusConnection *connection, /* FIXME do this on a lower level */ return FALSE; #endif - + return dbus_connection_get_socket(connection, fd); } @@ -5079,7 +5081,7 @@ dbus_connection_get_unix_fd (DBusConnection *connection, * If the connection is not socket-based, this function will return FALSE, * even if the connection does have a file descriptor of some kind. * i.e. this function always returns specifically a socket file descriptor. - * + * * @param connection the connection * @param fd return location for the file descriptor. * @returns #TRUE if fd is successfully obtained. @@ -5092,9 +5094,9 @@ dbus_connection_get_socket(DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (connection->transport != NULL, FALSE); - + CONNECTION_LOCK (connection); - + retval = _dbus_transport_get_socket_fd (connection->transport, fd); @@ -5134,7 +5136,7 @@ dbus_connection_get_unix_user (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (uid != NULL, FALSE); - + CONNECTION_LOCK (connection); if (!_dbus_transport_get_is_authenticated (connection->transport)) @@ -5146,7 +5148,7 @@ dbus_connection_get_unix_user (DBusConnection *connection, #ifdef DBUS_WIN _dbus_assert (!result); #endif - + CONNECTION_UNLOCK (connection); return result; @@ -5170,7 +5172,7 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (pid != NULL, FALSE); - + CONNECTION_LOCK (connection); if (!_dbus_transport_get_is_authenticated (connection->transport)) @@ -5191,7 +5193,7 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, * connection. * * @param connection the connection - * @param data return location for audit data + * @param data return location for audit data * @returns #TRUE if audit data is filled in with a valid ucred pointer */ dbus_bool_t @@ -5204,7 +5206,7 @@ dbus_connection_get_adt_audit_session_data (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (data != NULL, FALSE); _dbus_return_val_if_fail (data_size != NULL, FALSE); - + CONNECTION_LOCK (connection); if (!_dbus_transport_get_is_authenticated (connection->transport)) @@ -5234,7 +5236,7 @@ dbus_connection_get_adt_audit_session_data (DBusConnection *connection, * However, the function will never be called, because there are * no UNIX user ids to pass to it, or at least none of the existing * auth protocols would allow authenticating as a UNIX user on Windows. - * + * * @param connection the connection * @param function the predicate * @param data data to pass to the predicate @@ -5250,7 +5252,7 @@ dbus_connection_set_unix_user_function (DBusConnection *connection, DBusFreeFunction old_free_function = NULL; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_unix_user_function (connection->transport, function, data, free_data_function, @@ -5281,7 +5283,7 @@ dbus_connection_set_unix_user_function (DBusConnection *connection, * The return value indicates whether the user SID is available; * if it's available but we don't have the memory to copy it, * then the return value is #TRUE and #NULL is given as the SID. - * + * * @todo We would like to be able to say "You can ask the bus to tell * you the user of another connection though if you like; this is done * with dbus_bus_get_windows_user()." But this has to be implemented @@ -5300,7 +5302,7 @@ dbus_connection_get_windows_user (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (windows_sid_p != NULL, FALSE); - + CONNECTION_LOCK (connection); if (!_dbus_transport_get_is_authenticated (connection->transport)) @@ -5312,7 +5314,7 @@ dbus_connection_get_windows_user (DBusConnection *connection, #ifdef DBUS_UNIX _dbus_assert (!result); #endif - + CONNECTION_UNLOCK (connection); return result; @@ -5333,7 +5335,7 @@ dbus_connection_get_windows_user (DBusConnection *connection, * be invoked when the connection is freed or a new function is set. * However, the function will never be called, because there is no * way right now to authenticate as a Windows user on UNIX. - * + * * @param connection the connection * @param function the predicate * @param data data to pass to the predicate @@ -5349,7 +5351,7 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti DBusFreeFunction old_free_function = NULL; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_windows_user_function (connection->transport, function, data, free_data_function, @@ -5366,7 +5368,7 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti * #TRUE (the default is #FALSE), then the connection can proceed even if * the client does not authenticate as some user identity, i.e. clients * can connect anonymously. - * + * * This setting interacts with the available authorization mechanisms * (see dbus_server_set_auth_mechanisms()). Namely, an auth mechanism * such as ANONYMOUS that supports anonymous auth must be included in @@ -5382,7 +5384,7 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti * You can override the rules for connections authorized as a * user identity with dbus_connection_set_unix_user_function() * and dbus_connection_set_windows_user_function(). - * + * * @param connection the connection * @param value whether to allow authentication as an anonymous user */ @@ -5391,7 +5393,7 @@ dbus_connection_set_allow_anonymous (DBusConnection *connection, dbus_bool_t value) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_allow_anonymous (connection->transport, value); CONNECTION_UNLOCK (connection); @@ -5419,7 +5421,7 @@ dbus_connection_set_route_peer_messages (DBusConnection *connection, dbus_bool_t value) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); connection->route_peer_messages = TRUE; CONNECTION_UNLOCK (connection); @@ -5453,7 +5455,7 @@ dbus_connection_add_filter (DBusConnection *connection, DBusFreeFunction free_data_function) { DBusMessageFilter *filter; - + _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (function != NULL, FALSE); @@ -5462,7 +5464,7 @@ dbus_connection_add_filter (DBusConnection *connection, return FALSE; filter->refcount.value = 1; - + CONNECTION_LOCK (connection); if (!_dbus_list_append (&connection->filter_list, @@ -5477,11 +5479,11 @@ dbus_connection_add_filter (DBusConnection *connection, * so we don't run the free_user_data_function * if the add_filter() fails */ - + filter->function = function; filter->user_data = user_data; filter->free_user_data_function = free_data_function; - + CONNECTION_UNLOCK (connection); return TRUE; } @@ -5505,14 +5507,14 @@ dbus_connection_remove_filter (DBusConnection *connection, { DBusList *link; DBusMessageFilter *filter; - + _dbus_return_if_fail (connection != NULL); _dbus_return_if_fail (function != NULL); - + CONNECTION_LOCK (connection); filter = NULL; - + link = _dbus_list_get_last_link (&connection->filter_list); while (link != NULL) { @@ -5523,14 +5525,14 @@ dbus_connection_remove_filter (DBusConnection *connection, { _dbus_list_remove_link (&connection->filter_list, link); filter->function = NULL; - + break; } - + link = _dbus_list_get_prev_link (&connection->filter_list, link); filter = NULL; } - + CONNECTION_UNLOCK (connection); #ifndef DBUS_DISABLE_CHECKS @@ -5541,14 +5543,14 @@ dbus_connection_remove_filter (DBusConnection *connection, return; } #endif - + /* Call application code */ if (filter->free_user_data_function) (* filter->free_user_data_function) (filter->user_data); filter->free_user_data_function = NULL; filter->user_data = NULL; - + _dbus_message_filter_unref (filter); } @@ -5573,7 +5575,7 @@ dbus_connection_try_register_object_path (DBusConnection *connectio { char **decomposed_path; dbus_bool_t retval; - + _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (path != NULL, FALSE); _dbus_return_val_if_fail (path[0] == '/', FALSE); @@ -5803,10 +5805,10 @@ dbus_connection_get_object_path_data (DBusConnection *connection, _dbus_return_val_if_fail (data_p != NULL, FALSE); *data_p = NULL; - + if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL)) return FALSE; - + CONNECTION_LOCK (connection); *data_p = _dbus_object_tree_get_user_data_unlocked (connection->objects, (const char**) decomposed_path); @@ -5863,7 +5865,7 @@ _DBUS_DEFINE_GLOBAL_LOCK (connection_slots); * The passed-in slot must be initialized to -1, and is filled in * with the slot ID. If the passed-in slot is not -1, it's assumed * to be already allocated, and its refcount is incremented. - * + * * The allocated slot is global, i.e. all DBusConnection objects will * have a slot with the given integer ID reserved. * @@ -5893,7 +5895,7 @@ void dbus_connection_free_data_slot (dbus_int32_t *slot_p) { _dbus_return_if_fail (*slot_p >= 0); - + _dbus_data_slot_allocator_free (&slot_allocator, slot_p); } @@ -5931,14 +5933,14 @@ dbus_connection_set_data (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (slot >= 0, FALSE); - + SLOTS_LOCK (connection); retval = _dbus_data_slot_list_set (&slot_allocator, &connection->slot_list, slot, data, free_data_func, &old_free_func, &old_data); - + SLOTS_UNLOCK (connection); if (retval) @@ -5975,13 +5977,13 @@ dbus_connection_get_data (DBusConnection *connection, void *res; _dbus_return_val_if_fail (connection != NULL, NULL); - + SLOTS_LOCK (connection); res = _dbus_data_slot_list_get (&slot_allocator, &connection->slot_list, slot); - + SLOTS_UNLOCK (connection); return res; @@ -5995,7 +5997,7 @@ dbus_connection_get_data (DBusConnection *connection, */ void dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe) -{ +{ _dbus_modify_sigpipe = will_modify_sigpipe != FALSE; } @@ -6003,7 +6005,7 @@ dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe) * Specifies the maximum size message this connection is allowed to * receive. Larger messages will result in disconnecting the * connection. - * + * * @param connection a #DBusConnection * @param size maximum message size the connection can receive, in bytes */ @@ -6012,7 +6014,7 @@ dbus_connection_set_max_message_size (DBusConnection *connection, long size) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_max_message_size (connection->transport, size); @@ -6031,7 +6033,7 @@ dbus_connection_get_max_message_size (DBusConnection *connection) long res; _dbus_return_val_if_fail (connection != NULL, 0); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_max_message_size (connection->transport); CONNECTION_UNLOCK (connection); @@ -6091,7 +6093,7 @@ dbus_connection_get_max_message_unix_fds (DBusConnection *connection) * * Thus, the max live messages size can actually be exceeded * by up to the maximum size of a single message. - * + * * Also, if we read say 1024 bytes off the wire in a single read(), * and that contains a half-dozen small messages, we may exceed the * size max by that amount. But this should be inconsequential. @@ -6107,7 +6109,7 @@ dbus_connection_set_max_received_size (DBusConnection *connection, long size) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_max_received_size (connection->transport, size); @@ -6126,7 +6128,7 @@ dbus_connection_get_max_received_size (DBusConnection *connection) long res; _dbus_return_val_if_fail (connection != NULL, 0); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_max_received_size (connection->transport); CONNECTION_UNLOCK (connection); diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 28cfc8b..f907c12 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -108,7 +108,7 @@ _dbus_object_tree_new (DBusConnection *connection) if (tree->root == NULL) goto oom; tree->root->invoke_as_fallback = TRUE; - + return tree; oom: @@ -188,7 +188,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, _dbus_verbose (" searching children of %s for %s\n", subtree->name, path[0]); #endif - + i = 0; j = subtree->n_subtrees; while (i < j) @@ -203,7 +203,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, path[0], subtree->subtrees[k]->name, v); #endif - + if (v == 0) { if (index_in_parent) @@ -219,7 +219,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, DBusObjectSubtree *next; next = find_subtree_recurse (subtree->subtrees[k], - &path[1], create_if_not_found, + &path[1], create_if_not_found, index_in_parent, exact_match); if (next == NULL && subtree->invoke_as_fallback) @@ -237,7 +237,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, } else return find_subtree_recurse (subtree->subtrees[k], - &path[1], create_if_not_found, + &path[1], create_if_not_found, index_in_parent, exact_match); } else if (v < 0) @@ -254,7 +254,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, _dbus_verbose (" no match found, current tree %s, create_if_not_found = %d\n", subtree->name, create_if_not_found); #endif - + if (create_if_not_found) { DBusObjectSubtree* child; @@ -264,7 +264,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, _dbus_verbose (" creating subtree %s\n", path[0]); #endif - + child = _dbus_object_subtree_new (path[0], NULL, NULL); if (child == NULL) @@ -288,16 +288,16 @@ find_subtree_recurse (DBusObjectSubtree *subtree, subtree->max_subtrees = new_max_subtrees; } - /* The binary search failed, so i == j points to the + /* The binary search failed, so i == j points to the place the child should be inserted. */ child_pos = i; _dbus_assert (child_pos < new_n_subtrees && new_n_subtrees <= subtree->max_subtrees); if (child_pos + 1 < new_n_subtrees) { - memmove (&subtree->subtrees[child_pos+1], - &subtree->subtrees[child_pos], - (new_n_subtrees - child_pos - 1) * + memmove (&subtree->subtrees[child_pos+1], + &subtree->subtrees[child_pos], + (new_n_subtrees - child_pos - 1) * sizeof subtree->subtrees[0]); } subtree->subtrees[child_pos] = child; @@ -308,7 +308,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, child->parent = subtree; return find_subtree_recurse (child, - &path[1], create_if_not_found, + &path[1], create_if_not_found, index_in_parent, exact_match); } else @@ -329,7 +329,7 @@ find_subtree (DBusObjectTree *tree, #if VERBOSE_FIND _dbus_verbose ("Looking for exact registered subtree\n"); #endif - + subtree = find_subtree_recurse (tree->root, path, FALSE, index_in_parent, NULL); if (subtree && subtree->message_function == NULL) @@ -359,7 +359,7 @@ find_handler (DBusObjectTree *tree, _dbus_assert (exact_match != NULL); *exact_match = FALSE; /* ensure always initialized */ - + return find_subtree_recurse (tree->root, path, FALSE, NULL, exact_match); } @@ -463,7 +463,7 @@ _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, _dbus_warn ("Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n", path[0] ? path[0] : "null", path[1] ? path[1] : "null"); - goto unlock; + goto unlock; } #else _dbus_assert (subtree != NULL); @@ -575,12 +575,12 @@ _dbus_object_tree_list_registered_unlocked (DBusObjectTree *tree, { DBusObjectSubtree *subtree; char **retval; - + _dbus_assert (parent_path != NULL); _dbus_assert (child_entries != NULL); *child_entries = NULL; - + subtree = lookup_subtree (tree, parent_path); if (subtree == NULL) { @@ -607,7 +607,7 @@ _dbus_object_tree_list_registered_unlocked (DBusObjectTree *tree, } out: - + *child_entries = retval; return retval != NULL; } @@ -629,11 +629,11 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, /* We have the connection lock here */ already_unlocked = FALSE; - + _dbus_verbose (" considering default Introspect() handler...\n"); reply = NULL; - + if (!dbus_message_is_method_call (message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) @@ -645,12 +645,12 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, _dbus_verbose ("unlock\n"); _dbus_connection_unlock (tree->connection); } - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } _dbus_verbose (" using default Introspect() handler!\n"); - + if (!_dbus_string_init (&xml)) { #ifdef DBUS_BUILD_TESTS @@ -672,7 +672,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, if (!_dbus_string_append (&xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE)) goto out; - + if (!_dbus_string_append (&xml, "\n")) goto out; @@ -697,19 +697,19 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, v_STRING = _dbus_string_get_const_data (&xml); if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &v_STRING)) goto out; - + #ifdef DBUS_BUILD_TESTS if (tree->connection) #endif { already_unlocked = TRUE; - + if (!_dbus_connection_send_and_unlock (tree->connection, reply, NULL)) goto out; } - + result = DBUS_HANDLER_RESULT_HANDLED; - + out: #ifdef DBUS_BUILD_TESTS if (tree->connection) @@ -721,12 +721,12 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, _dbus_connection_unlock (tree->connection); } } - + _dbus_string_free (&xml); dbus_free_string_array (children); if (reply) dbus_message_unref (reply); - + return result; } @@ -745,7 +745,8 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, */ DBusHandlerResult _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, - DBusMessage *message) + DBusMessage *message, + dbus_bool_t *found_object) { char **path; dbus_bool_t exact_match; @@ -753,11 +754,11 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, DBusList *link; DBusHandlerResult result; DBusObjectSubtree *subtree; - + #if 0 _dbus_verbose ("Dispatch of message by object path\n"); #endif - + path = NULL; if (!dbus_message_get_path_decomposed (message, &path)) { @@ -768,7 +769,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_verbose ("unlock\n"); _dbus_connection_unlock (tree->connection); } - + _dbus_verbose ("No memory to get decomposed path\n"); return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -783,14 +784,17 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_verbose ("unlock\n"); _dbus_connection_unlock (tree->connection); } - + _dbus_verbose ("No path field in message\n"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } - + /* Find the deepest path that covers the path in the message */ subtree = find_handler (tree, (const char**) path, &exact_match); - + + if (found_object) + *found_object = !!subtree; + /* Build a list of all paths that cover the path in the message */ list = NULL; @@ -841,7 +845,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, #if 0 _dbus_verbose (" (invoking a handler)\n"); #endif - + #ifdef DBUS_BUILD_TESTS if (tree->connection) #endif @@ -890,14 +894,14 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_connection_unlock (tree->connection); } } - + while (list != NULL) { link = _dbus_list_get_first_link (&list); _dbus_object_subtree_unref (link->data); _dbus_list_remove_link (&list, link); } - + dbus_free_string_array (path); return result; @@ -920,7 +924,7 @@ _dbus_object_tree_get_user_data_unlocked (DBusObjectTree *tree, _dbus_assert (tree != NULL); _dbus_assert (path != NULL); - + /* Find the deepest path that covers the path in the message */ subtree = find_handler (tree, (const char**) path, &exact_match); @@ -1043,7 +1047,7 @@ _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, result = _dbus_object_tree_list_registered_unlocked (tree, parent_path, child_entries); - + #ifdef DBUS_BUILD_TESTS if (tree->connection) #endif @@ -1063,7 +1067,7 @@ _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, * Decompose an object path. A path of just "/" is * represented as an empty vector of strings. * The path need not be nul terminated. - * + * * @param data the path data * @param len the length of the path string * @param path address to store new object path @@ -1081,12 +1085,12 @@ _dbus_decompose_path (const char* data, _dbus_assert (data != NULL); _dbus_assert (path != NULL); - + #if VERBOSE_DECOMPOSE _dbus_verbose ("Decomposing path \"%s\"\n", data); #endif - + n_components = 0; if (len > 1) /* if path is not just "/" */ { @@ -1099,7 +1103,7 @@ _dbus_decompose_path (const char* data, ++i; } } - + retval = dbus_new0 (char*, n_components + 1); if (retval == NULL) @@ -1113,7 +1117,7 @@ _dbus_decompose_path (const char* data, while (comp < n_components) { _dbus_assert (i < len); - + if (data[i] == '/') ++i; j = i; @@ -1130,7 +1134,7 @@ _dbus_decompose_path (const char* data, _dbus_verbose (" (component in [%d,%d))\n", i, j); #endif - + retval[comp] = _dbus_memdup (&data[i], j - i + 1); if (retval[comp] == NULL) { @@ -1147,11 +1151,11 @@ _dbus_decompose_path (const char* data, i = j; } _dbus_assert (i == len); - + *path = retval; if (path_len) *path_len = n_components; - + return TRUE; } @@ -1174,16 +1178,16 @@ flatten_path (const char **path) else { int i; - + i = 0; while (path[i]) { if (!_dbus_string_append_byte (&str, '/')) goto nomem; - + if (!_dbus_string_append (&str, path[i])) goto nomem; - + ++i; } } @@ -1208,7 +1212,7 @@ flatten_path (const char **path) #include "dbus-test.h" #include -typedef enum +typedef enum { STR_EQUAL, STR_PREFIX, @@ -1345,7 +1349,7 @@ do_register (DBusObjectTree *tree, _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path) == &tree_test_data[i]); - + return TRUE; } @@ -1362,7 +1366,7 @@ do_test_dispatch (DBusObjectTree *tree, char *flat; message = NULL; - + flat = flatten_path (path); if (flat == NULL) goto oom; @@ -1382,7 +1386,7 @@ do_test_dispatch (DBusObjectTree *tree, ++j; } - result = _dbus_object_tree_dispatch_and_unlock (tree, message); + result = _dbus_object_tree_dispatch_and_unlock (tree, message, NULL); if (result == DBUS_HANDLER_RESULT_NEED_MEMORY) goto oom; @@ -1464,7 +1468,7 @@ run_decompose_tests (void) return FALSE; expected_len = string_array_length (decompose_tests[i].result); - + if (result_len != (int) string_array_length ((const char**)result) || expected_len != result_len || path_contains (decompose_tests[i].result, @@ -1490,7 +1494,7 @@ run_decompose_tests (void) ++i; } - + return TRUE; } @@ -1513,7 +1517,7 @@ object_tree_test_iteration (void *data) if (!run_decompose_tests ()) return FALSE; - + tree = NULL; tree = _dbus_object_tree_new (NULL); @@ -1542,7 +1546,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_handler (tree, path6, &exact_match) == tree->root && !exact_match); _dbus_assert (find_handler (tree, path7, &exact_match) == tree->root && !exact_match); _dbus_assert (find_handler (tree, path8, &exact_match) == tree->root && !exact_match); - + if (!do_register (tree, path1, TRUE, 1, tree_test_data)) goto out; @@ -1590,20 +1594,20 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree (tree, path6, NULL)); _dbus_assert (!find_subtree (tree, path7, NULL)); _dbus_assert (!find_subtree (tree, path8, NULL)); - + if (!do_register (tree, path4, TRUE, 4, tree_test_data)) goto out; _dbus_assert (find_subtree (tree, path0, NULL)); _dbus_assert (find_subtree (tree, path1, NULL)); _dbus_assert (find_subtree (tree, path2, NULL)); - _dbus_assert (find_subtree (tree, path3, NULL)); + _dbus_assert (find_subtree (tree, path3, NULL)); _dbus_assert (find_subtree (tree, path4, NULL)); _dbus_assert (!find_subtree (tree, path5, NULL)); _dbus_assert (!find_subtree (tree, path6, NULL)); _dbus_assert (!find_subtree (tree, path7, NULL)); _dbus_assert (!find_subtree (tree, path8, NULL)); - + if (!do_register (tree, path5, TRUE, 5, tree_test_data)) goto out; @@ -1675,7 +1679,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_handler (tree, path6, &exact_match) != tree->root && exact_match); _dbus_assert (find_handler (tree, path7, &exact_match) != tree->root && exact_match); _dbus_assert (find_handler (tree, path8, &exact_match) != tree->root && exact_match); - + /* test the list_registered function */ { @@ -1763,7 +1767,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path1); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path1) == NULL); @@ -1789,7 +1793,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path3); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path3) == NULL); @@ -1802,7 +1806,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path4); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path4) == NULL); @@ -1815,7 +1819,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path5); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path5) == NULL); @@ -1828,7 +1832,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path6); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path6) == NULL); @@ -1867,7 +1871,7 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree (tree, path6, NULL)); _dbus_assert (!find_subtree (tree, path7, NULL)); _dbus_assert (!find_subtree (tree, path8, NULL)); - + i = 0; while (i < (int) _DBUS_N_ELEMENTS (tree_test_data)) { @@ -1877,7 +1881,7 @@ object_tree_test_iteration (void *data) } /* Register it all again, and test dispatch */ - + if (!do_register (tree, path0, TRUE, 0, tree_test_data)) goto out; if (!do_register (tree, path1, FALSE, 1, tree_test_data)) @@ -1919,7 +1923,7 @@ object_tree_test_iteration (void *data) goto out; if (!do_test_dispatch (tree, path8, 8, tree_test_data, _DBUS_N_ELEMENTS (tree_test_data))) goto out; - + out: if (tree) { diff --git a/dbus/dbus-object-tree.h b/dbus/dbus-object-tree.h index 022dd93..1cba2a0 100644 --- a/dbus/dbus-object-tree.h +++ b/dbus/dbus-object-tree.h @@ -4,7 +4,7 @@ * Copyright (C) 2003 Red Hat Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -42,7 +42,8 @@ dbus_bool_t _dbus_object_tree_register (DBusObjectTree void _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, const char **path); DBusHandlerResult _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, - DBusMessage *message); + DBusMessage *message, + dbus_bool_t *found_object); void* _dbus_object_tree_get_user_data_unlocked (DBusObjectTree *tree, const char **path); void _dbus_object_tree_free_all_unlocked (DBusObjectTree *tree); -- 1.7.4.1