summaryrefslogtreecommitdiff
path: root/bus/dispatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'bus/dispatch.c')
-rw-r--r--bus/dispatch.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c
index a80476cd..05b44362 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -259,21 +259,30 @@ bus_dispatch (DBusConnection *connection,
/* Assign a sender to the message */
if (bus_connection_is_active (connection))
{
+ const char *old_sender;
+
sender = bus_connection_get_name (connection);
_dbus_assert (sender != NULL);
- if (!dbus_message_set_sender (message, sender))
+ /* hopefully the sending connection already got this right - if it did,
+ * we can skip resetting it, saving a realloc */
+ old_sender = dbus_message_get_sender (message);
+
+ if (old_sender == NULL || strcmp (old_sender, sender) != 0)
{
- BUS_SET_OOM (&error);
- goto out;
- }
+ if (!dbus_message_set_sender (message, sender))
+ {
+ BUS_SET_OOM (&error);
+ goto out;
+ }
- /* We need to refetch the service name here, because
- * dbus_message_set_sender can cause the header to be
- * reallocated, and thus the service_name pointer will become
- * invalid.
- */
- service_name = dbus_message_get_destination (message);
+ /* We need to refetch the service name here, because
+ * dbus_message_set_sender can cause the header to be
+ * reallocated, and thus the service_name pointer will become
+ * invalid.
+ */
+ service_name = dbus_message_get_destination (message);
+ }
}
if (service_name &&