Here are my CVS diffs which fix the handle leaking problem. I also fixed a couple of NULL pointer problems.

Index: auth_client.c
===================================================================
RCS file: /cvsroot/sofia-sip/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c,v
retrieving revision 1.5
diff -r1.5 auth_client.c
725c725,730
<   sip_request_t *rq = sip->sip_request;
---
>   sip_request_t *rq;
>
>   if ( !sip->sip_request )
>         return -1;
> > rq = sip->sip_request;
Index: nua.c
===================================================================
RCS file: /cvsroot/sofia-sip/sofia-sip/libsofia-sip-ua/nua/nua.c,v
retrieving revision 1.20
diff -r1.20 nua.c
1405c1405,1406
<       nua_handle_ref(nh);
---
> // No need to get a ref since it is never freed
> //      nua_handle_ref(nh);
Index: nua_register.c
===================================================================
RCS file: /cvsroot/sofia-sip/sofia-sip/libsofia-sip-ua/nua/nua_register.c,v
retrieving revision 1.3
diff -r1.3 nua_register.c
195a196,199
> // Make sure we have something to expire... > if (!sip)
>     return;
>
Index: nua_session.c
===================================================================
RCS file: /cvsroot/sofia-sip/sofia-sip/libsofia-sip-ua/nua/nua_session.c,v
retrieving revision 1.3
diff -r1.3 nua_session.c
1379a1380,1382
>   // Go ahead and remove the dialog too.
>   nsession_destroy( nh );
>
Index: nua_stack.c
===================================================================
RCS file: /cvsroot/sofia-sip/sofia-sip/libsofia-sip-ua/nua/nua_stack.c,v
retrieving revision 1.41
diff -r1.41 nua_stack.c
569c569,570
<       nua_handle_ref(nh);
---
> // No need to get a ref since it never gets freed.
> //      nua_handle_ref(nh);




Colin Whittaker wrote:
I think I found a memory leak.
It appears memory for handles is not being freed after the nua_handle_destroy().
The su_block_t sub_ref = 1.
So there appears to be one extra reference which is not being unreferenced.

I've been adding trace code and think I understand what may be going on here.
Each nua_xxx... function gets a reference in nua_signal().
This reference is freed at the end of nua_stack_signal().
When an event is received for a handle from the network, nua_stack_event() gets a reference.
This reference is freed after the nua callback is called in nua_event().
Other references a obtained for dialog usage as well.

The only reference I could not find a corresponding un-reference call for is in nua_stack_signal() at the very beginning:

 if (nh) {
   if (!nh->nh_prev)
     nh_append(nua, nh);
   if (!nh->nh_ref_by_stack) {
     nh->nh_ref_by_stack = 1;
     nua_handle_ref(nh);
   }
 }

I think the nua_handle_ref() call is extraneous here. Handles created by the stack in nh_create() do not get a reference.

Handles created by the stack, seem to have the same problem in nua_event():

 if (nh && !NH_IS_DEFAULT(nh)) {
   if (!nh->nh_ref_by_user && nh->nh_valid) {
     nh->nh_ref_by_user = 1;
     nua_handle_ref(nh);
   }
 }

I don't see any place where this reference is ever unreferenced.

Also, incoming INVITEs that get canceled seem to create handles which get the first reference in nua_dialog_usage_add(), but never calls nua_dialog_usage_remove(). I also see this, if the application calls nua_handle_destroy() in the callback for events nua_r_bye or nua_r_cancel.

Colin..





-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sofia-sip-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sofia-sip-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to