THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Víctor Seva (linuxmaniac)
Attached to Project - sip-router Summary - dialplan: allow match/subst rules with variables Task Type - Improvement Category - Module Status - New Assigned To - Víctor Seva Operating System - All Severity - Low Priority - Normal Reported Version - Development Due in Version - Undecided Due Date - Undecided Details - This allows the use of pv's at match and subst rules on dialplan module.
One or more files have been attached.
More information can be found at the following URL: https://sip-router.org/tracker/index.php?do=details&task_id=429
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
sip-router writes:
Details - This allows the use of pv's at match and subst rules on dialplan module.
is there any performance penalty compared to current version when pvs are not used?
-- juha
On 05/17/2014 06:42 AM, Juha Heinanen wrote:
sip-router writes:
Details - This allows the use of pv's at match and subst rules on dialplan module.
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.
pv_check_format code is in the first patch
relevant code in build_rule():
/*compile the expressions, and if ok, build the rule */ dpl_node_t * build_rule(db_val_t * values) @@ -359,9 +463,10 @@ dpl_node_t * build_rule(db_val_t * values) pcre *match_comp, *subst_comp; struct subst_expr *repl_comp; dpl_node_t * new_rule;
- str match_exp, subst_exp, repl_exp, attrs;
str match_exp, subst_exp, repl_exp, attrs, tmp; int matchop; int cap_cnt=0;
unsigned int pv_flags = 0;
matchop = VAL_INT(values+2);
@@ -377,11 +482,21 @@ dpl_node_t * build_rule(db_val_t * values)
GET_STR_VALUE(match_exp, values, 3); if(matchop == DP_REGEX_OP){
match_comp = reg_ex_comp(match_exp.s, &cap_cnt);
if(!match_comp){
LM_ERR("failed to compile match expression %.*s\n",
match_exp.len, match_exp.s);
goto err;
if(check_pv_marker(match_exp, &tmp))
pv_flags |= DP_PV_MATCH_M;
if(pv_check_format(&tmp)<0){
pv_flags &= ~DP_PV_MATCH_MASK;
match_comp = reg_ex_comp(match_exp.s, &cap_cnt);
if(!match_comp){
LM_ERR("failed to compile match expression %.*s\n",
match_exp.len, match_exp.s);
goto err;
}
}
else{
pv_flags |= DP_PV_MATCH;
LM_DBG("match_exp DP_PV_MATCH_MASK\n");
} }match_comp = NULL;
@@ -398,26 +513,38 @@ dpl_node_t * build_rule(db_val_t * values)
GET_STR_VALUE(subst_exp, values, 5); if(subst_exp.s && subst_exp.len){
subst_comp = reg_ex_comp(subst_exp.s, &cap_cnt);
if(!subst_comp){
LM_ERR("failed to compile subst expression %.*s\n",
subst_exp.len, subst_exp.s);
goto err;
if(check_pv_marker(subst_exp, &tmp))
pv_flags |= DP_PV_SUBST_M;
if(pv_check_format(&tmp)<0){
pv_flags &= ~DP_PV_SUBST_MASK;
subst_comp = reg_ex_comp(subst_exp.s, &cap_cnt);
if(!subst_comp){
LM_ERR("failed to compile subst expression %.*s\n",
subst_exp.len, subst_exp.s);
goto err;
}
if (cap_cnt > MAX_REPLACE_WITH) {
LM_ERR("subst expression %.*s has too many sub-expressions\n",
subst_exp.len, subst_exp.s);
goto err;
}}
if (cap_cnt > MAX_REPLACE_WITH) {
LM_ERR("subst expression %.*s has too many sub-expressions\n",
subst_exp.len, subst_exp.s);
goto err;
else{
pv_flags |= DP_PV_SUBST;
LM_DBG("subst_exp DP_PV_SUBST_MASK\n");
} }subst_comp = NULL;
- if (repl_comp && (cap_cnt < repl_comp->max_pmatch) &&
(repl_comp->max_pmatch != 0)) {
LM_ERR("repl_exp %.*s refers to %d sub-expressions, but "
"subst_exp %.*s has only %d\n",
repl_exp.len, repl_exp.s, repl_comp->max_pmatch,
subst_exp.len, subst_exp.s, cap_cnt);
goto err;
if((pv_flags&DP_PV_MASK)==0) {
if (repl_comp && (cap_cnt < repl_comp->max_pmatch) &&
(repl_comp->max_pmatch != 0)) {
LM_ERR("repl_exp %.*s refers to %d sub-expressions, but "
"subst_exp %.*s has only %d\n",
repl_exp.len, repl_exp.s, repl_comp->max_pmatch,
subst_exp.len, subst_exp.s, cap_cnt);
goto err;
}
}
new_rule = (dpl_node_t *)shm_malloc(sizeof(dpl_node_t));
@@ -450,6 +577,7 @@ dpl_node_t * build_rule(db_val_t * values) new_rule->match_comp = match_comp; new_rule->subst_comp = subst_comp; new_rule->repl_comp = repl_comp;
new_rule->pv_flags = pv_flags;
return new_rule;
@@ -550,6 +678,85 @@ err: return -1; }
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.
-- juha
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; }