[asterisk-dev] [Code Review] 4303: res_pjsip_outbound_registration: Fix reference leak.

Kevin Harwell reviewboard at asterisk.org
Fri Jan 2 17:40:06 CST 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4303/#review14070
-----------------------------------------------------------


Actually, response->client_state *should* be being unreffed (see "registration_response_destroy") as response gets cleaned up by its RAII_VAR in "handle_registration_response". So something else must be leaking the ref.

What else is odd is that "client_state" object passed into the registration_response_cb (via the pjsip_regc_cbparam -> token) does not seem to have a ref initially added for it when handed to the underlying pjsip code (see the "pjsip_regc_create" function in "sip_outbound_registration_regc_alloc") unless I am missing something. So, I'd almost think the cleanup code on it in "sip_outbound_registration_response_cb" would cause a problem.

It looks like in "handle_client_registration" the client_state is being bumped everytime before sending. I don't think it needs to be. As mentioned the underlying pjsip framework maintains a pointer (a ref needs to be added as it doesn't have one now) that gets handed to the response callback.  I *think* if you add the initial ref on create and remove the one before send it will alleviate the extra ref.

- Kevin Harwell


On Dec. 30, 2014, 4:24 p.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4303/
> -----------------------------------------------------------
> 
> (Updated Dec. 30, 2014, 4:24 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> Every time a registration started, sip_outbound_registration_response_cb bumps the ref count on client_state then pushes a handle_registration_response task.  handle_registration_response never unreffed it though.  So every time a registration goes out, the ref count goes up by one.
> 
> This patch adds the unreffs to handle_registration_response.
> 
> 
> Diffs
> -----
> 
>   branches/13/res/res_pjsip_outbound_registration.c 430163 
> 
> Diff: https://reviewboard.asterisk.org/r/4303/diff/
> 
> 
> Testing
> -------
> 
> Watched the ref count on client_state in no-auth registrations, auth-successful registrations and auth-failed registrations to make sure the ref count stayed stable.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150102/ece29c6f/attachment.html>


More information about the asterisk-dev mailing list