aboutsummaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-02-04 20:12:28 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2010-03-19 17:48:00 +0000
commit3a2753e667e565f18f124b632fe720b70b018d05 (patch)
tree8cf1c687bd762ec9e658f75338b8d0b0abd78a3b /bus
parentff4aad0e88063b6807f4e74736d72812fec077d2 (diff)
downloaddbus-3a2753e667e565f18f124b632fe720b70b018d05.tar.gz
Move dispatching to destination to bus_dispatch_matches()
Diffstat (limited to 'bus')
-rw-r--r--bus/dispatch.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 9b5e65ab..2fc04307 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -101,10 +101,39 @@ bus_dispatch_matches (BusTransaction *transaction,
_dbus_assert (sender == NULL || bus_connection_is_active (sender));
_dbus_assert (dbus_message_get_sender (message) != NULL);
+ context = bus_transaction_get_context (transaction);
+
+ /* First, send the message to the addressed_recipient, if there is one. */
+ if (addressed_recipient != NULL)
+ {
+ if (!bus_context_check_security_policy (context, transaction,
+ sender, addressed_recipient,
+ addressed_recipient,
+ message, error))
+ return FALSE;
+
+ if (dbus_message_contains_unix_fds (message) &&
+ !dbus_connection_can_send_type (addressed_recipient,
+ DBUS_TYPE_UNIX_FD))
+ {
+ dbus_set_error (error,
+ DBUS_ERROR_NOT_SUPPORTED,
+ "Tried to send message with Unix file descriptors"
+ "to a client that doesn't support that.");
+ return FALSE;
+ }
+
+ /* Dispatch the message */
+ if (!bus_transaction_send (transaction, addressed_recipient, message))
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+ }
+
+ /* Now dispatch to others who look interested in this message */
connections = bus_transaction_get_connections (transaction);
-
dbus_error_init (&tmp_error);
- context = bus_transaction_get_context (transaction);
matchmaker = bus_context_get_matchmaker (context);
recipients = NULL;
@@ -304,34 +333,12 @@ bus_dispatch (DBusConnection *connection,
{
addressed_recipient = bus_service_get_primary_owners_connection (service);
_dbus_assert (addressed_recipient != NULL);
-
- if (!bus_context_check_security_policy (context, transaction,
- connection, addressed_recipient,
- addressed_recipient,
- message, &error))
- goto out;
-
- if (dbus_message_contains_unix_fds(message) &&
- !dbus_connection_can_send_type(addressed_recipient, DBUS_TYPE_UNIX_FD))
- {
- dbus_set_error(&error,
- DBUS_ERROR_NOT_SUPPORTED,
- "Tried to send message with Unix file descriptors"
- "to a client that doesn't support that.");
- goto out;
- }
-
- /* Dispatch the message */
- if (!bus_transaction_send (transaction, addressed_recipient, message))
- {
- BUS_SET_OOM (&error);
- goto out;
- }
}
}
- /* Now match the messages against any match rules, which will send
- * out signals and such. addressed_recipient may == NULL.
+ /* Now send the message to its destination (or not, if
+ * addressed_recipient == NULL), and match it against other connections'
+ * match rules.
*/
if (!bus_dispatch_matches (transaction, connection, addressed_recipient, message, &error))
goto out;