[telepathy-gabble/master] Don't leak streams on SessionHandler.Error()

Will Thompson will.thompson at collabora.co.uk
Wed Apr 29 09:25:30 PDT 2009


---
 src/media-channel.c                          |    2 ++
 tests/twisted/jingle/stream-handler-error.py |   25 +++++++++++++++----------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/media-channel.c b/src/media-channel.c
index eedfd03..4ca5840 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -2801,6 +2801,8 @@ gabble_media_channel_error (TpSvcMediaSessionHandler *iface,
       GabbleMediaStream *stream = g_ptr_array_index (tmp, i);
 
       gabble_media_stream_error (stream, errno, message, NULL);
+
+      g_object_unref (stream);
     }
 
   g_ptr_array_free (tmp, TRUE);
diff --git a/tests/twisted/jingle/stream-handler-error.py b/tests/twisted/jingle/stream-handler-error.py
index 27c2f90..e25a2b2 100644
--- a/tests/twisted/jingle/stream-handler-error.py
+++ b/tests/twisted/jingle/stream-handler-error.py
@@ -4,13 +4,15 @@ test for a bug introduced by 54021cee0ad38 which removed an idle callback
 masking refcounting assumptions.
 """
 
+from functools import partial
+
 from gabbletest import exec_test
 from servicetest import make_channel_proxy
 import jingletest
 
 import constants as cs
 
-def test(q, bus, conn, stream):
+def test(q, bus, conn, stream, call_error_on):
     jt = jingletest.JingleTest(stream, 'test at localhost', 'foo at bar.com/Foo')
 
     conn.Connect()
@@ -34,18 +36,21 @@ def test(q, bus, conn, stream):
 
     media_chan_suffix = e.path
 
-    # S-E gets notified about new session handler, and calls Ready on it
     e = q.expect('dbus-signal', signal='NewSessionHandler')
     session_handler = make_channel_proxy(conn, e.args[0], 'Media.SessionHandler')
-    session_handler.Ready()
 
-    e = q.expect('dbus-signal', signal='NewStreamHandler')
+    if call_error_on == 'session':
+        session_handler.Error(0, "this has been deprecated for years")
+    else:
+        session_handler.Ready()
+
+        e = q.expect('dbus-signal', signal='NewStreamHandler')
 
-    # S-E gets notified about a newly-created stream
-    stream_handler = make_channel_proxy(conn, e.args[0], 'Media.StreamHandler')
+        # S-E gets notified about a newly-created stream
+        stream_handler = make_channel_proxy(conn, e.args[0], 'Media.StreamHandler')
 
-    # Something goes wrong immediately!
-    stream_handler.Error(0, "i'll have the eggs tostada please")
+        # Something goes wrong immediately!
+        stream_handler.Error(0, "i'll have the eggs tostada please")
 
     # Gabble doesn't fall over, and the channel closes nicely.
     e = q.expect('dbus-signal', signal='Closed', path=media_chan_suffix)
@@ -54,5 +59,5 @@ def test(q, bus, conn, stream):
     q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
 
 if __name__ == '__main__':
-    exec_test(test)
-
+    exec_test(partial(test, call_error_on='stream'))
+    exec_test(partial(test, call_error_on='session'))
-- 
1.5.6.5




More information about the telepathy-commits mailing list