[telepathy-gabble/master] Destroy JingleFactory's soup session first

Will Thompson will.thompson at collabora.co.uk
Mon Jun 29 11:00:08 PDT 2009


Destroying the SoupSession makes it call all the callbacks for
outstanding HTTP requests with an error, which means all the outstanding
Google relay requests end before we try to close all the channels that
were waiting for them.

Fixes fd.o#120387

Reviewed-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
---
 src/jingle-factory.c                 |   12 ++++++------
 tests/twisted/jingle/google-relay.py |   31 +++++++++++++++++++++++--------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/src/jingle-factory.c b/src/jingle-factory.c
index e277846..ce4f2eb 100644
--- a/src/jingle-factory.c
+++ b/src/jingle-factory.c
@@ -445,6 +445,12 @@ gabble_jingle_factory_dispose (GObject *object)
   DEBUG ("dispose called");
   priv->dispose_has_run = TRUE;
 
+  if (priv->soup != NULL)
+    {
+      g_object_unref (priv->soup);
+      priv->soup = NULL;
+    }
+
   g_hash_table_destroy (priv->sessions);
   priv->sessions = NULL;
 
@@ -459,12 +465,6 @@ gabble_jingle_factory_dispose (GObject *object)
   g_free (fac->priv->relay_token);
   g_free (fac->priv->relay_server);
 
-  if (priv->soup != NULL)
-    {
-      g_object_unref (priv->soup);
-      priv->soup = NULL;
-    }
-
   if (G_OBJECT_CLASS (gabble_jingle_factory_parent_class)->dispose)
     G_OBJECT_CLASS (gabble_jingle_factory_parent_class)->dispose (object);
 }
diff --git a/tests/twisted/jingle/google-relay.py b/tests/twisted/jingle/google-relay.py
index 51b0439..ec1a950 100644
--- a/tests/twisted/jingle/google-relay.py
+++ b/tests/twisted/jingle/google-relay.py
@@ -69,6 +69,7 @@ magic_cookie=MMMMMMMM
 
 TOO_SLOW_CLOSE = 1
 TOO_SLOW_REMOVE_SELF = 2
+TOO_SLOW_DISCONNECT = 3
 
 def test(q, bus, conn, stream, incoming=True, too_slow=None):
     jt = jingletest.JingleTest(stream, 'test at localhost', 'foo at bar.com/Foo')
@@ -307,18 +308,26 @@ def test_too_slow(q, bus, conn, stream, httpd, media_chan, too_slow):
     elif too_slow == TOO_SLOW_REMOVE_SELF:
         media_chan.RemoveMembers([conn.GetSelfHandle()], "",
             dbus_interface=cs.CHANNEL_IFACE_GROUP)
+    elif too_slow == TOO_SLOW_DISCONNECT:
+        conn.Disconnect()
 
-    q.expect('dbus-signal', signal='Closed')
+    q.expect('dbus-signal', signal='Closed',
+        path=media_chan.object_path[len(tp_path_prefix):])
 
-    # Now Google answers!
-    httpd.handle_request()
-    httpd.handle_request()
+    # If we've disconnected, Gabble's no longer waiting for the reply. The
+    # Closed signal arriving proves that calling Disconnect() while Gabble was
+    # waiting for an http response didn't crash it (see
+    # <http://bugs.freedesktop.org/show_bug.cgi?id=22535>).
+    if too_slow != TOO_SLOW_DISCONNECT:
+        # Now Google answers!
+        httpd.handle_request()
+        httpd.handle_request()
 
-    # Make a misc method call to check that Gabble's still alive.
-    sync_dbus(bus, q, conn)
+        # Make a misc method call to check that Gabble's still alive.
+        sync_dbus(bus, q, conn)
 
-    conn.Disconnect()
-    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+        conn.Disconnect()
+        q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
 
 
 if __name__ == '__main__':
@@ -338,3 +347,9 @@ if __name__ == '__main__':
     exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=False,
                                       too_slow=TOO_SLOW_REMOVE_SELF),
             protocol=GoogleXmlStream)
+    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=True,
+                                      too_slow=TOO_SLOW_DISCONNECT),
+            protocol=GoogleXmlStream)
+    exec_test(lambda q, b, c, s: test(q, b, c, s, incoming=False,
+                                      too_slow=TOO_SLOW_DISCONNECT),
+            protocol=GoogleXmlStream)
-- 
1.5.6.5



More information about the telepathy-commits mailing list