summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2018-01-15 16:31:53 +0000
committerSimon McVittie <smcv@collabora.com>2018-02-16 15:27:05 +0000
commitc6b91129facf88d7b30540b0073973bbf7ca5bb4 (patch)
tree7a52c8b73d73b3b8d3b1250cd3e2690576fe58ce
parent02170d6fa6454521fc7590fe9d84a47504f7c797 (diff)
bus_transaction_send: Take sender and destination connections
We'll need this if we want to stamp optional header fields on the message according to the preferences of the recipient(s). Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
-rw-r--r--bus/connection.c25
-rw-r--r--bus/connection.h3
-rw-r--r--bus/dispatch.c7
3 files changed, 18 insertions, 17 deletions
diff --git a/bus/connection.c b/bus/connection.c
index 91b1966eb..87f2f8a9d 100644
--- a/bus/connection.c
+++ b/bus/connection.c
@@ -2311,7 +2311,7 @@ bus_transaction_capture (BusTransaction *transaction,
{
DBusConnection *recipient = link->data;
- if (!bus_transaction_send (transaction, recipient, message))
+ if (!bus_transaction_send (transaction, sender, recipient, message))
goto out;
}
@@ -2420,12 +2420,13 @@ bus_transaction_send_from_driver (BusTransaction *transaction,
return TRUE;
}
- return bus_transaction_send (transaction, connection, message);
+ return bus_transaction_send (transaction, NULL, connection, message);
}
dbus_bool_t
bus_transaction_send (BusTransaction *transaction,
- DBusConnection *connection,
+ DBusConnection *sender,
+ DBusConnection *destination,
DBusMessage *message)
{
MessageToSend *to_send;
@@ -2442,15 +2443,15 @@ bus_transaction_send (BusTransaction *transaction,
dbus_message_get_member (message) : "(unset)",
dbus_message_get_error_name (message) ?
dbus_message_get_error_name (message) : "(unset)",
- dbus_connection_get_is_connected (connection) ?
+ dbus_connection_get_is_connected (destination) ?
"" : " (disconnected)");
_dbus_assert (dbus_message_get_sender (message) != NULL);
- if (!dbus_connection_get_is_connected (connection))
- return TRUE; /* silently ignore disconnected connections */
+ if (!dbus_connection_get_is_connected (destination))
+ return TRUE; /* silently ignore disconnected destinations */
- d = BUS_CONNECTION_DATA (connection);
+ d = BUS_CONNECTION_DATA (destination);
_dbus_assert (d != NULL);
to_send = dbus_new (MessageToSend, 1);
@@ -2459,7 +2460,7 @@ bus_transaction_send (BusTransaction *transaction,
return FALSE;
}
- to_send->preallocated = dbus_connection_preallocate_send (connection);
+ to_send->preallocated = dbus_connection_preallocate_send (destination);
if (to_send->preallocated == NULL)
{
dbus_free (to_send);
@@ -2474,13 +2475,13 @@ bus_transaction_send (BusTransaction *transaction,
if (!_dbus_list_prepend (&d->transaction_messages, to_send))
{
- message_to_send_free (connection, to_send);
+ message_to_send_free (destination, to_send);
return FALSE;
}
_dbus_verbose ("prepended message\n");
- /* See if we already had this connection in the list
+ /* See if we already had this destination in the list
* for this transaction. If we have a pending message,
* then we should already be in transaction->connections
*/
@@ -2500,10 +2501,10 @@ bus_transaction_send (BusTransaction *transaction,
if (link == NULL)
{
- if (!_dbus_list_prepend (&transaction->connections, connection))
+ if (!_dbus_list_prepend (&transaction->connections, destination))
{
_dbus_list_remove (&d->transaction_messages, to_send);
- message_to_send_free (connection, to_send);
+ message_to_send_free (destination, to_send);
return FALSE;
}
}
diff --git a/bus/connection.h b/bus/connection.h
index 9e253ae51..141fb0c0b 100644
--- a/bus/connection.h
+++ b/bus/connection.h
@@ -132,7 +132,8 @@ typedef void (* BusTransactionCancelFunction) (void *data);
BusTransaction* bus_transaction_new (BusContext *context);
BusContext* bus_transaction_get_context (BusTransaction *transaction);
dbus_bool_t bus_transaction_send (BusTransaction *transaction,
- DBusConnection *connection,
+ DBusConnection *sender,
+ DBusConnection *destination,
DBusMessage *message);
dbus_bool_t bus_transaction_capture (BusTransaction *transaction,
DBusConnection *connection,
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 4ae98b5e0..b16ad2b3a 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -108,9 +108,7 @@ send_one_message (DBusConnection *connection,
return TRUE; /* don't send it but don't return an error either */
}
- if (!bus_transaction_send (transaction,
- connection,
- message))
+ if (!bus_transaction_send (transaction, sender, connection, message))
{
BUS_SET_OOM (error);
return FALSE;
@@ -165,7 +163,8 @@ bus_dispatch_matches (BusTransaction *transaction,
}
/* Dispatch the message */
- if (!bus_transaction_send (transaction, addressed_recipient, message))
+ if (!bus_transaction_send (transaction, sender, addressed_recipient,
+ message))
{
BUS_SET_OOM (error);
return FALSE;