[asterisk-dev] [Code Review] 2579: Add vtable and methods for to_json and to_ami for Stasis messages

David Lee reviewboard at asterisk.org
Tue Jun 4 11:21:21 CDT 2013



> On May 30, 2013, 11:44 p.m., opticron wrote:
> > I'm not so sure that NULL-safety on a ao2_ref variant is such a good idea when ao2_ref is not NULL-safe.
> > 
> > Be ready to lose a merge race on the confbridge changes.
> 
> Matt Jordan wrote:
>     I'm with Kinsey on this one. While I can certainly see why you're doing it - checking each return and returning NULL and on the success path bumping it by one and returning the same pointer is a bit tedious - it feels like this could be abused. In general, people shouldn't be ref bumping something that is NULL.

Okay, fine. But if my fingers fall off from the extra typing, I blame you two!


> On May 30, 2013, 11:44 p.m., opticron wrote:
> > /trunk/main/stasis_message.c, lines 148-150
> > <https://reviewboard.asterisk.org/r/2579/diff/1/?file=38866#file38866line148>
> >
> >     I'm not sure it's ever reasonable to blindly invoke a virtual function on a NULL message. A message that failed allocation should never be published.

It's true that the message won't be published, but there are other use cases where you end up with a NULL message (such as with caching). It's easy enough to make the function NULL safe, so I'm sticking with it.


- David


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


On May 30, 2013, 10:42 p.m., David Lee wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2579/
> -----------------------------------------------------------
> 
> (Updated May 30, 2013, 10:42 p.m.)
> 
> 
> Review request for Asterisk Developers, Matt Jordan and Jason Parker.
> 
> 
> Bugs: ASTERISK-21817
>     https://issues.asterisk.org/jira/browse/ASTERISK-21817
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> When a Stasis message type is defined in a loadable module, handling
> those messages for AMI and res_stasis events can be cumbersome.
> 
> This patch adds a vtable to stasis_message_type, with to_ami and
> to_json virtual functions. These allow messages to be handled
> abstractly without putting module-specific code in core.
> 
> As an example, the VarSet AMI event was refactored to use the to_ami
> virtual function.
> 
> Additionally, I finally got tired of the boilerplate incrementing AO2
> refcounts, so I added an ao2_ref1() macro, which is NULL safe and
> returns the object.
> 
> 
> Diffs
> -----
> 
>   /trunk/apps/confbridge/confbridge_manager.c 390151 
>   /trunk/include/asterisk/astobj2.h 390151 
>   /trunk/include/asterisk/manager.h 390151 
>   /trunk/include/asterisk/stasis.h 390151 
>   /trunk/main/manager.c 390151 
>   /trunk/main/manager_channels.c 390151 
>   /trunk/main/parking.c 390151 
>   /trunk/main/stasis_channels.c 390151 
>   /trunk/main/stasis_message.c 390151 
>   /trunk/tests/test_astobj2.c 390151 
>   /trunk/tests/test_stasis.c 390151 
>   /trunk/tests/test_stasis_channels.c 390151 
> 
> Diff: https://reviewboard.asterisk.org/r/2579/diff/
> 
> 
> Testing
> -------
> 
> Unit tests.
> 
> Verified that the VarSet event still looked the way it ought to.
> 
> 
> Thanks,
> 
> David Lee
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130604/eb3e83c8/attachment.htm>


More information about the asterisk-dev mailing list