On 05/17/2014 11:14 AM, Juha Heinanen wrote:
> Victor Seva writes:
> 
>>> is there any performance penalty compared to current version when pvs
>>> are not used?
>>
>> Calling to the new core function pv_check_format(str *) in the load
>> process in order to detect if the match/subst rule has pv vars.
> 
> performance penalty during load of rules from dialplan table is fine as
> long as there is no penalty to dp_translate() call.

You can see that if the flag is not matched nothing changes there.

>  #define DP_MAX_ATTRS_LEN     128
>  static char dp_attrs_buf[DP_MAX_ATTRS_LEN+1];
>  int translate(struct sip_msg *msg, str input, str *output, dpl_id_p idp,
>               str *attrs)
>  {
>       dpl_node_p rulep;
> +     dpl_pv_node_p rule_pv;
>       dpl_index_p indexp;
> +     pcre *match_comp = NULL;
>       int user_len, rez;
>       char b;
>  
> @@ -339,7 +486,27 @@ search_rule:
>  
>                       case DP_REGEX_OP:
>                               LM_DBG("regex operator testing\n");
> -                             rez = pcre_exec(rulep->match_comp, NULL, 
> input.s, input.len,
> +                             if(rulep->pv_flags&DP_PV_MATCH) {
> +                                     if(!msg) {
> +                                             LM_ERR("Cannot translate using 
> a regex match with pv "
> +                                                     "without message\n");
> +                                             continue;
> +                                     }
> +                                     rule_pv = get_pv_rule(rulep, 
> idp->dp_id, user_len);
> +                                     if(rule_pv) {
> +                                             if(build_pv_comp(msg, 
> rule_pv)<0){
> +                                                     LM_ERR("error rule 
> regex comp. Skip this\n");
> +                                                     continue;
> +                                             }
> +                                             match_comp = 
> rule_pv->match_comp;
> +                                     }
> +                                     else {
> +                                             LM_ERR("pv rule not found.Skip 
> this\n");
> +                                             continue;
> +                                     }
> +                             }
> +                             else match_comp = rulep->match_comp;
> +                             rez = pcre_exec(match_comp, NULL, input.s, 
> input.len,
>                                               0, 0, NULL, 0);
>                               break;
>  
> @@ -382,8 +549,9 @@ search_rule:
>       return -1;
>  
>  repl:
> -     LM_DBG("found a matching rule %p: pr %i, match_exp %.*s\n",
> -                     rulep, rulep->pr, rulep->match_exp.len, 
> rulep->match_exp.s);
> +     LM_DBG("found a matching rule %p: pr %i, match_exp %.*s pv_flags:%d\n",
> +                     rulep, rulep->pr, rulep->match_exp.len, 
> rulep->match_exp.s,
> +                     rulep->pv_flags);
>  
>       if(attrs) {
>               attrs->len = 0;
> @@ -405,7 +573,10 @@ repl:
>               }
>       }
>  
> -     if(rule_translate(msg, input, rulep, output)!=0){
> +     if(!(rulep->pv_flags&DP_PV_MASK))
> +             rule_pv = NULL;
> +
> +     if(rule_translate(msg, input, rulep, rule_pv, output)!=0){
>               LM_ERR("could not build the output\n");
>               return -1;
>       }


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