[sr-dev] git:sr_3.0: core: fix selects in optimized rvalue expressions
Andrei Pelinescu-Onciul
andrei at iptel.org
Thu Aug 19 16:11:46 CEST 2010
Module: sip-router
Branch: sr_3.0
Commit: d36e9bfbfda41773973ad1822c5905c0cd4dc71e
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d36e9bfbfda41773973ad1822c5905c0cd4dc71e
Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date: Fri Jun 18 22:22:59 2010 +0200
core: fix selects in optimized rvalue expressions
- do not attempt to resolve_select() twice the same select. This
happened when a rve containing only a select was optimized,
the select moved out of the rve and fix_expr() tried to "fix"
the already resolved select later.
- changed BUG() messages for failed resolve_select() into ERR().
(cherry picked from commit a7fa13ed757d74cfd4486f3c282ec50259929edc)
---
route.c | 20 ++++++++++++++------
route_struct.h | 5 +++--
rvalue.c | 2 +-
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/route.c b/route.c
index 13608a2..9d9e94d 100644
--- a/route.c
+++ b/route.c
@@ -580,7 +580,9 @@ int fix_expr(struct expr* exp)
exp->r.re=re;
exp->r_type=RE_ST;
}else if (exp->r_type!=RE_ST && exp->r_type != AVP_ST
- && exp->r_type != SELECT_ST && exp->r_type!= RVE_ST
+ && exp->r_type != SELECT_ST &&
+ exp->r_type != SELECT_UNFIXED_ST &&
+ exp->r_type!= RVE_ST
&& exp->r_type != PVAR_ST){
LOG(L_CRIT, "BUG: fix_expr : invalid type for match\n");
return E_BUG;
@@ -593,19 +595,21 @@ int fix_expr(struct expr* exp)
return ret;
}
}
- if (exp->l_type==SELECT_O) {
+ if (exp->l_type==SELECT_UNFIXED_O) {
if ((ret=resolve_select(exp->l.select)) < 0) {
- BUG("Unable to resolve select\n");
+ ERR("Unable to resolve select\n");
print_select(exp->l.select);
return ret;
}
+ exp->l_type=SELECT_O;
}
- if ((exp->r_type==SELECT_O)||(exp->r_type==SELECT_ST)) {
+ if (exp->r_type==SELECT_UNFIXED_ST) {
if ((ret=resolve_select(exp->r.select)) < 0) {
- BUG("Unable to resolve select\n");
- print_select(exp->l.select);
+ ERR("Unable to resolve select\n");
+ print_select(exp->r.select);
return ret;
}
+ exp->r_type=SELECT_ST;
}
/* PVAR don't need fixing */
ret=0;
@@ -1745,6 +1749,10 @@ inline static int eval_elem(struct run_act_ctx* h, struct expr* e,
case PVAR_O:
ret=comp_pvar(e->op, e->l.param, e->r_type, &e->r, msg, h);
break;
+
+ case SELECT_UNFIXED_O:
+ BUG("unexpected unfixed select operand %d\n", e->l_type);
+ break;
/*
default:
LOG(L_CRIT, "BUG: eval_elem: invalid operand %d\n",
diff --git a/route_struct.h b/route_struct.h
index 4894bd5..3f7e854 100644
--- a/route_struct.h
+++ b/route_struct.h
@@ -76,7 +76,7 @@ enum _expr_l_type{
METHOD_O=51, URI_O, FROM_URI_O, TO_URI_O, SRCIP_O, SRCPORT_O,
DSTIP_O, DSTPORT_O, PROTO_O, AF_O, MSGLEN_O, ACTION_O,
NUMBER_O, AVP_O, SNDIP_O, SNDPORT_O, TOIP_O, TOPORT_O, SNDPROTO_O,
- SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O};
+ SNDAF_O, RETCODE_O, SELECT_O, PVAR_O, RVEXP_O, SELECT_UNFIXED_O};
/* action types */
enum action_type{
FORWARD_T=1, SEND_T, DROP_T, LOG_T, ERROR_T, ROUTE_T, EXEC_T,
@@ -121,7 +121,8 @@ enum _operand_subtype{
SELECT_ST, PVAR_ST,
LVAL_ST, RVE_ST,
RETCODE_ST, CASE_ST,
- BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST
+ BLOCK_ST, JUMPTABLE_ST, CONDTABLE_ST, MATCH_CONDTABLE_ST,
+ SELECT_UNFIXED_ST
};
typedef enum _expr_l_type expr_l_type;
diff --git a/rvalue.c b/rvalue.c
index 22a7b2b..b17e664 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -2761,7 +2761,7 @@ static int fix_rval(struct rvalue* rv)
return fix_actions(rv->v.action);
case RV_SEL:
if (resolve_select(&rv->v.sel)<0){
- BUG("Unable to resolve select\n");
+ ERR("Unable to resolve select\n");
print_select(&rv->v.sel);
}
return 0;
More information about the sr-dev
mailing list