[glib] GDBusMessage: Don't reset serial number when copying
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDBusMessage: Don't reset serial number when copying
- Date: Thu, 9 Sep 2010 19:17:01 +0000 (UTC)
commit 7c6606854400ba2a4d0c5b5a0eb96ba90845f82e
Author: David Zeuthen <davidz redhat com>
Date: Thu Sep 9 15:15:13 2010 -0400
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: David Zeuthen <davidz redhat com>
gio/gdbusconnection.h | 12 ++++++------
gio/gdbusmessage.c | 3 ++-
gio/gdbusprivate.c | 6 ------
gio/tests/gdbus-message.c | 2 +-
4 files changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/gio/gdbusconnection.h b/gio/gdbusconnection.h
index 4e3a80a..eb3e0f3 100644
--- a/gio/gdbusconnection.h
+++ b/gio/gdbusconnection.h
@@ -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
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index c618105..0aca1e0 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -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)
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index a9c4ce5..ca2680b 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -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,
diff --git a/gio/tests/gdbus-message.c b/gio/tests/gdbus-message.c
index 981a951..b3be200 100644
--- a/gio/tests/gdbus-message.c
+++ b/gio/tests/gdbus-message.c
@@ -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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]