[asterisk-dev] [Code Review] 3971: astobj2.c/refcounter.py: Fix to deal with invalid object refs.

Corey Farrell reviewboard at asterisk.org
Mon Sep 15 19:13:40 CDT 2014



> On Sept. 15, 2014, 7:07 p.m., Corey Farrell wrote:
> > /branches/1.8/contrib/scripts/refcounter.py, lines 118-119
> > <https://reviewboard.asterisk.org/r/3971/diff/1/?file=67190#file67190line118>
> >
> >     This can be optimized if invalid objects are given curcount == -1, that way it wouldn't have to do substring comparison again.
> 
> rmudgett wrote:
>     I'm not seeing the optimization.  Are you referring to avoiding the "'invalid' not in parsed_line['state']" comparison?  That only happens when the object is destroyed or is invalid.

Yes, I'm referring to the check for 'invalid' on line 119.  Not major, but this comparison would happen once for every object.  Not doing a string comparison would be slightly faster (current_object[obj]['curcount'] < 0 instead of checking for 'invalid').

Feel free to discard this finding if you disagree, it's a minor optimization.


- Corey


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


On Sept. 2, 2014, 10:22 p.m., rmudgett wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/3971/
> -----------------------------------------------------------
> 
> (Updated Sept. 2, 2014, 10:22 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: AFS-155 and ASTERISK-24295
>     https://issues.asterisk.org/jira/browse/AFS-155
>     https://issues.asterisk.org/jira/browse/ASTERISK-24295
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> * Make astob2 REF_DEBUG output an invalid object line when an invalid ao2 object ref/unref is attempted.  This is similar to the constructor/destructor lines.
> 
> * Fixed refcounter.py to handle skewed objects that have constructor/destructor states.
> 
> * Made refcounter.py highlight the invalid ao2 object refs by putting them in their own section of the processed output file.
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/main/astobj2.c 422535 
>   /branches/1.8/contrib/scripts/refcounter.py 422535 
> 
> Diff: https://reviewboard.asterisk.org/r/3971/diff/
> 
> 
> Testing
> -------
> 
> Instigated a REF_DEBUG log that reffed destroyed objects to get an invalid line in the ref debug log file.
> The patched script doesn't have an excpetion on a previous invalid ref debug log that had code unreffing a destroyed object.
> The patched script now highlights the invalid objects in the log.
> 
> 
> Thanks,
> 
> rmudgett
> 
>

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


More information about the asterisk-dev mailing list