]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
bus_transaction_send: Take sender and destination connections
authorSimon McVittie <smcv@collabora.com>
Mon, 15 Jan 2018 16:31:53 +0000 (16:31 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 16 Feb 2018 15:27:05 +0000 (15:27 +0000)
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

bus/connection.c
bus/connection.h
bus/dispatch.c

index 91b1966eb671bc933c5da51bf0e17bebefaaaf7e..87f2f8a9debe9a276713c4e25449777fccc17add 100644 (file)
@@ -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;
         }
     }
index 9e253ae51222a0f7f791f53c284606b1961f6c5d..141fb0c0bc7583755ac315317ed0cabef3fb6c11 100644 (file)
@@ -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,
index 4ae98b5e04a42b8166652b47ffa8850cee4b701e..b16ad2b3a095e44dd4f257d821f8f9692ddc8007 100644 (file)
@@ -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;