Hi again Kai,

> >a) in step 2, when calling su_glib_root_gsource(), am I
>> >getting a NEW reference to the GSource? This is, do I need a
>> >g_source_unref() for each su_glib_root_gsource()?
>>
>> it's a new reference, so you need to unref it.
>>
>>
> Ok, I expected that.
>
>
>> >b) Is su_root_destroy() calling g_source_unref() for the GSource?
>>
>> It's calling it for additional references (these are
>> indirect references from other parts of sofia-sip using
>> the mainloop), but the initial reference is owned by
>> the caller of su_glib_root_gsource().
>>
>>
> Ok, great.
>
>
Just made some changes in my code according to what I had understood from
your answers, but it seems I didn't catch all of it right. Got an assert
from sofia-sip when running it.

My source is more or less like this one:

 root =  su_glib_root_create(NULL); ---> 1st reference to the GSource
internally created
 source = su_glib_root_gsource(root); --> 2nd reference of the GSource
 g_source_attach(source, glib_context); --> 3rd reference of the GSource
inside the GLib context

 /* Run loop */

g_source_destroy(source); /* Unref-ed the reference which was in the GLib
context */
g_source_unref(source); /* Unref-ed the reference I got with
su_glib_root_gsource() */
su_root_destroy(root); /* Unref-ed the reference inside the root object */

And the assert is:
su_root.c:508: su_root_destroy: Assertion `(self->sur_task->sut_port &&
su_port_own_thread(self->sur_task->sut_port))' failed.


I checked the source in one of the examples you gave me, and found that
actually su_glib_root_gsource() doesn't seem to return a new reference of
the GSource, but just the same reference as the one stored inside the root
object. So, it seems the proper code would be:

 root =  su_glib_root_create(NULL); ---> 1st reference to the GSource
internally created
 source = su_glib_root_gsource(root); --> No new reference
 g_source_attach(source, glib_context); --> 2nd reference of the GSource
inside the GLib context

 /* Run loop */

g_source_destroy(source); /* Unref-ed the reference which was in the GLib
context */
su_root_destroy(root); /* Unref-ed the reference inside the root object */


Is this second piece of code right? If so, then the documentation of
su_glib_root_gsource() is pretty confusing, as it says:
"Note that you need to unref the GSource with g_source_unref() before
destroying the root object." Really seems you are getting a new reference
with su_glib_root_gsource() which you later need to unref(), while this
seems not true.


Cheers,
-Aleksander
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to