On 10/13/2014 09:52 AM, sip-router wrote:
> THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
> 
> The following task has a new comment added:
> 
> FS#429 - dialplan: allow match/subst rules with variables
> User who did this - Daniel-Constantin Mierla (miconda)
> 
> ----------
> I pushed to master branch an alternative implementation. It took a while to 
> analyze the patch, being quite big -- there are couple of issues that could 
> have been fixed (such as: module might be used by workers with negative rank, 
> like timer or rpc -- there is a mi/rpc command for translation; return at 
> first pv detected in a string to mark it as a string with vars; handling 
> ending $ and allowing $$ in values), but the main issue is that cloning data 
> in private memory is not really feasible always, because can be tons of 
> dialplan db records. It would mean to have each process with a lot of pkg 
> memory.
> 
> Only parsing of values can be cached (to have the broken down list of static 
> strings and variables). But given that parsed values have to be searched 
> anyhow in a hash table, I expected to be no real performance difference than 
> parsing every time. Evaluating the value at runtime, compiling and freeing 
> PCRE have to be done for each attempt to match in dialplan rules. Considering 
> the complexity of managing a private cache of parsed values, my patch is 
> parsing the values at runtime, if they are detected to have variables at load 
> time.
> 
> In summary, the way it was done:
> 
> - detection stops at first variable found in a value -- the function has been 
> added in dialplan to cope properly with $ at the end of values
> 
> - each value for match and subst is marked with a flag during load if there 
> is a var inside it
> 
> - when it is a var in a value that ends with a single $, in memory it is 
> stored with $$ at the end (one more $ is added at the end), so at runtime the 
> evaluation results in a single $. It avoids keeping other flags and doing 
> more conditions at runtime to cope with single $ parsing
> 
> - parsing of values to tokenize variables is done at runtime, with compile of 
> PCRE and afferent freeing afterwards
> 
> - there is a module parameter 'match_dynamic' that has to be set to 1 in 
> order to enable this feature
> 
> Let me know if anyone has comments on this approach, if not, I will close 
> this item.

I'd implemented the use of avps with '[*]' index all on the match/subst
rules with my implamentation [0]

dialplan rule having an avp with index all([*]) will be checked with the
avp values one by one.
Example:
Having $(avp(s:list)[*]) -> "111", "222"
'^(00|\+)?$(avp(s:list)[*])$' will be checked as:
 - '^(00|\+)?111$'
 - '^(00|\+)?222$'

Do you think this can be useful to the community?

I'm going to work on this but with the actual implementation in master
of variables in match/subst. Using here github issues to manage task,
patches [1]

[0]
https://github.com/linuxmaniac/kamailio/commit/d204db8a03bc9797871fd444366bd9a38ef19daa

[1] https://github.com/kamailio/kamailio/issues/5

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to