[asterisk-dev] [Code Review] 4185: sorcery: Make ast_sorcery_is_object_field_registered handle field names that are regexes.

George Joseph reviewboard at asterisk.org
Thu Nov 20 13:35:14 CST 2014



> On Nov. 20, 2014, 11:53 a.m., Mark Michelson wrote:
> > branches/12/main/sorcery.c, lines 144-145
> > <https://reviewboard.asterisk.org/r/4185/diff/2/?file=69147#file69147line144>
> >
> >     Admittedly, I haven't used regex in C much, but looking at man pages, why have you elected to use a heap-allocated pointer for name_regex? Using a regex_t struct here seems like it would work better since you don't have to worry about an allocation failure and would have the regex_t stored directly with the ast_sorcery_object_field, as opposed to elsewhere in memory.

As Josh pointed out, non-regex situations are much more prevalent so I didn't want every field to pay the memory penalty for a regex_t structure.  Also there's no way to reliably determine if a regex_t has a valid compiled regex in it so the pointer is also the test for a valid regex.


- George


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


On Nov. 20, 2014, 11:17 a.m., George Joseph wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4185/
> -----------------------------------------------------------
> 
> (Updated Nov. 20, 2014, 11:17 a.m.)
> 
> 
> Review request for Asterisk Developers, Joshua Colp and Mark Michelson.
> 
> 
> Bugs: ASTERISK-24520
>     https://issues.asterisk.org/jira/browse/ASTERISK-24520
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> As a result of https://reviewboard.asterisk.org/r/3305, res_sorcery_realtime was tossing database fields that didn't have an exact match to a sorcery registered field.  This broke the ability to use regexes as field names which manifested itself as a failure of res_pjsip_phoneprov_provider which uses this capability.  It also broke handling of fields that start with '@' in realtime but I don't think anyone noticed.
> 
> This patch does the following...
> Modifies ast_sorcery_fields_register to pre-compile the name regex.
> Modifies ast_sorcery_is_object_field_registered to test the regex if it exists instead of doing an exact strcmp.
> Modifies res_pjsip_phoneprov_provider with a few tweaks to get it to work with realtime.
> 
> 
> Diffs
> -----
> 
>   branches/12/tests/test_sorcery.c 428504 
>   branches/12/res/res_pjsip_phoneprov_provider.c 428504 
>   branches/12/main/sorcery.c 428504 
> 
> Diff: https://reviewboard.asterisk.org/r/4185/diff/
> 
> 
> Testing
> -------
> 
> Tested by me with realtime phoneprov, aor and registration objects both with and without registered objects.
> Testsuite testing in progress.  EDIT: complete.  No issues.
> Will also be tested by John Kiniston who reported the res_pjsip_phoneprov_provider issue.  EDIT: complete.
> 
> 
> Thanks,
> 
> George Joseph
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141120/11b9b453/attachment-0001.html>


More information about the asterisk-dev mailing list