[glib/glib-2-26] Bug 632544 – Cannot send a locked message with PRESERVE_SERIAL flag



commit 62476cd0f7ca7d3becf81243fb7ac1b97cf7db51
Author: Peng Huang <shawn p huang gmail com>
Date:   Mon Dec 13 13:09:38 2010 -0500

    Bug 632544 â?? Cannot send a locked message with PRESERVE_SERIAL flag
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632544
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 gio/gdbusconnection.c        |    3 ++-
 gio/tests/gdbus-connection.c |   18 +++++++++++++++---
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index da2b9f9..cf12f41 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -1449,7 +1449,8 @@ g_dbus_connection_send_message_unlocked (GDBusConnection   *connection,
   if (out_serial != NULL)
     *out_serial = serial_to_use;
 
-  g_dbus_message_set_serial (message, serial_to_use);
+  if (!(flags & G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL))
+    g_dbus_message_set_serial (message, serial_to_use);
 
   g_dbus_message_lock (message);
   _g_dbus_worker_send_message (connection->worker,
diff --git a/gio/tests/gdbus-connection.c b/gio/tests/gdbus-connection.c
index 866e27c..5c2939e 100644
--- a/gio/tests/gdbus-connection.c
+++ b/gio/tests/gdbus-connection.c
@@ -880,6 +880,18 @@ test_connection_filter (void)
 
   m2 = g_dbus_message_copy (m, &error);
   g_assert_no_error (error);
+  g_dbus_message_set_serial (m2, data.serial);
+  /* lock the message to test PRESERVE_SERIAL flag. */
+  g_dbus_message_lock (m2);
+  g_dbus_connection_send_message (c, m2, G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL, &data.serial, &error);
+  g_object_unref (m2);
+  g_assert_no_error (error);
+
+  while (data.num_handled == 2)
+    g_thread_yield ();
+
+  m2 = g_dbus_message_copy (m, &error);
+  g_assert_no_error (error);
   r = g_dbus_connection_send_message_with_reply_sync (c,
                                                       m2,
                                                       G_DBUS_SEND_MESSAGE_FLAGS_NONE,
@@ -891,7 +903,7 @@ test_connection_filter (void)
   g_assert_no_error (error);
   g_assert (r != NULL);
   g_object_unref (r);
-  g_assert_cmpint (data.num_handled, ==, 3);
+  g_assert_cmpint (data.num_handled, ==, 4);
 
   g_dbus_connection_remove_filter (c, filter_id);
 
@@ -908,8 +920,8 @@ test_connection_filter (void)
   g_assert_no_error (error);
   g_assert (r != NULL);
   g_object_unref (r);
-  g_assert_cmpint (data.num_handled, ==, 3);
-  g_assert_cmpint (data.num_outgoing, ==, 3);
+  g_assert_cmpint (data.num_handled, ==, 4);
+  g_assert_cmpint (data.num_outgoing, ==, 4);
 
   /* this is safe; testserver will exit once the bus goes away */
   g_assert (g_spawn_command_line_async (SRCDIR "/gdbus-testserver.py", NULL));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]