[glib] GDBus: Fix bug in child enumeration
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDBus: Fix bug in child enumeration
- Date: Thu, 1 Jul 2010 17:09:07 +0000 (UTC)
commit 51ed44e7add7ca1d3b764f13df2cf80ebe32c3f9
Author: David Zeuthen <davidz redhat com>
Date: Thu Jul 1 13:06:56 2010 -0400
GDBus: Fix bug in child enumeration
Signed-off-by: David Zeuthen <davidz redhat com>
gio/gdbusconnection.c | 3 +--
gio/tests/gdbus-export.c | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index 2a3f2aa..281523a 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -3712,7 +3712,7 @@ introspect_append_standard_interfaces (GString *s)
static void
maybe_add_path (const gchar *path, gsize path_len, const gchar *object_path, GHashTable *set)
{
- if (g_str_has_prefix (object_path, path) && strlen (object_path) > path_len)
+ if (g_str_has_prefix (object_path, path) && strlen (object_path) > path_len && object_path[path_len-1] == '/')
{
const gchar *begin;
const gchar *end;
@@ -3720,7 +3720,6 @@ maybe_add_path (const gchar *path, gsize path_len, const gchar *object_path, GHa
begin = object_path + path_len;
end = strchr (begin, '/');
-
if (end != NULL)
s = g_strndup (begin, end - begin);
else
diff --git a/gio/tests/gdbus-export.c b/gio/tests/gdbus-export.c
index d1f3eed..63c871e 100644
--- a/gio/tests/gdbus-export.c
+++ b/gio/tests/gdbus-export.c
@@ -963,6 +963,7 @@ test_object_registration (void)
guint boss_foo_reg_id;
guint boss_bar_reg_id;
guint worker1_foo_reg_id;
+ guint worker1p1_foo_reg_id;
guint worker2_bar_reg_id;
guint intern1_foo_reg_id;
guint intern2_bar_reg_id;
@@ -1023,6 +1024,18 @@ test_object_registration (void)
num_successful_registrations++;
registration_id = g_dbus_connection_register_object (c,
+ "/foo/boss/worker1p1",
+ &foo_interface_info,
+ NULL,
+ &data,
+ on_object_unregistered,
+ &error);
+ g_assert_no_error (error);
+ g_assert (registration_id > 0);
+ worker1p1_foo_reg_id = registration_id;
+ num_successful_registrations++;
+
+ registration_id = g_dbus_connection_register_object (c,
"/foo/boss/worker2",
&bar_interface_info,
NULL,
@@ -1250,8 +1263,9 @@ test_object_registration (void)
nodes = get_nodes_at (c, "/foo/boss");
g_assert (nodes != NULL);
- g_assert_cmpint (g_strv_length (nodes), ==, 4);
+ g_assert_cmpint (g_strv_length (nodes), ==, 5);
g_assert (_g_strv_has_string ((const gchar* const *) nodes, "worker1"));
+ g_assert (_g_strv_has_string ((const gchar* const *) nodes, "worker1p1"));
g_assert (_g_strv_has_string ((const gchar* const *) nodes, "worker2"));
g_assert (_g_strv_has_string ((const gchar* const *) nodes, "interns"));
g_assert (_g_strv_has_string ((const gchar* const *) nodes, "executives"));
@@ -1311,6 +1325,17 @@ test_object_registration (void)
g_assert (_g_strv_has_string ((const gchar* const *) nodes, "evp2"));
g_strfreev (nodes);
+ /* This is to check that a bug (rather, class of bugs) in gdbusconnection.c's
+ *
+ * g_dbus_connection_list_registered_unlocked()
+ *
+ * where /foo/boss/worker1 reported a child '1', is now fixed.
+ */
+ nodes = get_nodes_at (c, "/foo/boss/worker1");
+ g_assert (nodes != NULL);
+ g_assert_cmpint (g_strv_length (nodes), ==, 0);
+ g_strfreev (nodes);
+
/* check that calls are properly dispatched to the functions in foo_vtable for objects
* implementing the org.example.Foo interface
*
@@ -1339,6 +1364,7 @@ test_object_registration (void)
g_assert (g_dbus_connection_unregister_object (c, boss_foo_reg_id));
g_assert (g_dbus_connection_unregister_object (c, boss_bar_reg_id));
g_assert (g_dbus_connection_unregister_object (c, worker1_foo_reg_id));
+ g_assert (g_dbus_connection_unregister_object (c, worker1p1_foo_reg_id));
g_assert (g_dbus_connection_unregister_object (c, worker2_bar_reg_id));
g_assert (g_dbus_connection_unregister_object (c, intern1_foo_reg_id));
g_assert (g_dbus_connection_unregister_object (c, intern2_bar_reg_id));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]