[telepathy-glib/master] Don't introspect a CM twice at once
Will Thompson
will.thompson at collabora.co.uk
Wed Aug 26 09:29:37 PDT 2009
Fixes fd.o#23524
Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
---
telepathy-glib/connection-manager.c | 21 +++++++++++++++------
tests/dbus/cm.c | 32 +++++++++++++++++++++++++++++---
2 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index 641ffc7..983da46 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -631,13 +631,18 @@ tp_connection_manager_got_protocols (TpConnectionManager *self,
}
static gboolean
+introspection_in_progress (TpConnectionManager *self)
+{
+ return self->priv->listing_protocols || self->priv->found_protocols != NULL;
+}
+
+static gboolean
tp_connection_manager_idle_introspect (gpointer data)
{
TpConnectionManager *self = data;
/* Start introspecting if we want to and we're not already */
- if (!self->priv->listing_protocols &&
- self->priv->found_protocols == NULL &&
+ if (!introspection_in_progress (self) &&
(self->always_introspect ||
self->info_source == TP_CM_INFO_SOURCE_NONE))
{
@@ -673,8 +678,7 @@ tp_connection_manager_name_owner_changed_cb (TpDBusDaemon *bus,
self->running = FALSE;
/* cancel pending introspection, if any */
- if (self->priv->listing_protocols ||
- self->priv->pending_protocols != NULL)
+ if (introspection_in_progress (self))
tp_connection_manager_end_introspection (self, &e);
g_signal_emit (self, signals[SIGNAL_EXITED], 0);
@@ -1633,8 +1637,13 @@ tp_connection_manager_new (TpDBusDaemon *dbus,
gboolean
tp_connection_manager_activate (TpConnectionManager *self)
{
- if (self->running)
- return FALSE;
+ if (self->running || introspection_in_progress (self))
+ {
+ DEBUG ("already %s", self->running ? "running" : "introspecting");
+ return FALSE;
+ }
+
+ DEBUG ("calling ListProtocols");
self->priv->listing_protocols = TRUE;
tp_cli_connection_manager_call_list_protocols (self, -1,
diff --git a/tests/dbus/cm.c b/tests/dbus/cm.c
index e5e288b..3d1ca45 100644
--- a/tests/dbus/cm.c
+++ b/tests/dbus/cm.c
@@ -751,12 +751,20 @@ test_complex_file_ready (Test *test,
g_free (name);
}
+static gboolean
+idle_activate (gpointer cm)
+{
+ tp_connection_manager_activate (cm);
+ return FALSE;
+}
+
static void
test_dbus_ready (Test *test,
- gconstpointer data G_GNUC_UNUSED)
+ gconstpointer data)
{
gchar *name;
guint info_source;
+ const gboolean activate = GPOINTER_TO_INT (data);
test->error = NULL;
test->cm = tp_connection_manager_new (test->dbus,
@@ -766,7 +774,22 @@ test_dbus_ready (Test *test,
g_assert (test->error == NULL);
g_test_queue_unref (test->cm);
- g_test_bug ("18291");
+ if (activate)
+ {
+ g_test_bug ("23524");
+
+ /* The bug being tested here was caused by ListProtocols being called
+ * twice on the same CM; this can be triggered by _activate()ing at
+ * exactly the wrong moment. But the wrong moment involves racing an
+ * idle. This triggered the assertion about 1/3 of the time on my laptop.
+ * --wjt
+ */
+ g_idle_add (idle_activate, test->cm);
+ }
+ else
+ {
+ g_test_bug ("18291");
+ }
tp_connection_manager_call_when_ready (test->cm, ready_or_not,
test, NULL, NULL);
@@ -862,7 +885,10 @@ main (int argc,
g_test_add ("/cm/file", Test, NULL, setup, test_file_ready, teardown);
g_test_add ("/cm/file (complex)", Test, NULL, setup,
test_complex_file_ready, teardown);
- g_test_add ("/cm/dbus", Test, NULL, setup, test_dbus_ready, teardown);
+ g_test_add ("/cm/dbus", Test, GINT_TO_POINTER (FALSE), setup,
+ test_dbus_ready, teardown);
+ g_test_add ("/cm/dbus-and-activate", Test, GINT_TO_POINTER (TRUE), setup,
+ test_dbus_ready, teardown);
g_test_add ("/cm/list", Test, NULL, setup, test_list, teardown);
--
1.5.6.5
More information about the telepathy-commits
mailing list