Commit 7c660685 authored by David Zeuthen's avatar David Zeuthen

GDBusMessage: Don't reset serial number when copying

Ryan pointed out that it's safe to do this because we have the
G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag and that it simplifies
how filter functions work.
Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
parent a51df8ce
......@@ -528,12 +528,12 @@ void g_dbus_connection_signal_unsubscribe (GDBusConnection
* return copy;
* }
* ]|
* If the returned #GDBusMessage is different from @message and the
* serial number is unset (e.g. zero), then @message's serial number
* will be used on the returned message (so in this case the returned
* message must be unlocked). Additionally, if the returned message
* cannot be sent on @connection, then a warning is logged to
* <emphasis>standard error</emphasis>.
* If the returned #GDBusMessage is different from @message and cannot
* be sent on @connection (it could use features, such as file
* descriptors, not compatible with @connection), then a warning is
* logged to <emphasis>standard error</emphasis>. Applications can
* check this ahead of time using g_dbus_message_to_blob() passing a
* #GDBusCapabilityFlags value obtained from @connection.
*
* Returns: (transfer full) (allow-none): A #GDBusMessage that will be freed with
* g_object_unref() or %NULL to drop the message. Passive filter
......
......@@ -3190,7 +3190,7 @@ g_dbus_message_lock (GDBusMessage *message)
*
* Copies @message. The copy is a deep copy and the returned
* #GDBusMessage is completely identical except that it is guaranteed
* to not be locked and the serial will be set to 0.
* to not be locked.
*
* This operation can fail if e.g. @message contains file descriptors
* and the per-process or system-wide open files limit is reached.
......@@ -3217,6 +3217,7 @@ g_dbus_message_copy (GDBusMessage *message,
ret->flags = message->flags;
ret->byte_order = message->byte_order;
ret->major_protocol_version = message->major_protocol_version;
ret->serial = message->serial;
#ifdef G_OS_UNIX
if (message->fd_list != NULL)
......
......@@ -1244,14 +1244,12 @@ maybe_write_next_message (GDBusWorker *worker)
*/
if (data != NULL)
{
guint32 old_serial;
GDBusMessage *old_message;
guchar *new_blob;
gsize new_blob_size;
GError *error;
old_message = data->message;
old_serial = g_dbus_message_get_serial (old_message);
data->message = _g_dbus_worker_emit_message_about_to_be_sent (worker, data->message);
if (data->message == old_message)
{
......@@ -1269,10 +1267,6 @@ maybe_write_next_message (GDBusWorker *worker)
else
{
/* filters altered the message -> reencode */
if (g_dbus_message_get_serial (data->message) == 0)
g_dbus_message_set_serial (data->message, old_serial);
error = NULL;
new_blob = g_dbus_message_to_blob (data->message,
&new_blob_size,
......
......@@ -108,7 +108,7 @@ message_copy (void)
g_assert_cmpint (G_OBJECT (m)->ref_count, ==, 1);
g_assert_cmpint (G_OBJECT (copy)->ref_count, ==, 1);
g_assert_cmpint (g_dbus_message_get_serial (copy), ==, 0);
g_assert_cmpint (g_dbus_message_get_serial (copy), ==, g_dbus_message_get_serial (m));
g_assert_cmpint (g_dbus_message_get_byte_order (copy), ==, g_dbus_message_get_byte_order (m));
g_assert_cmpint (g_dbus_message_get_flags (copy), ==, g_dbus_message_get_flags (m));
g_assert_cmpint (g_dbus_message_get_message_type (copy), ==, g_dbus_message_get_message_type (m));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment