Module: sip-router
Branch: master
Commit: 2f34ba7d8d36f1a8465055367d725b9af4117c99
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2f34ba7d8d36f1a8465055367d725b9af4117c99

Author: Andrei Pelinescu-Onciul <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
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().

---

 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 9a8f649..0e07556 100644
--- a/route.c
+++ b/route.c
@@ -588,7 +588,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;
@@ -601,19 +603,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;
@@ -1895,6 +1899,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 38a0eb7..9b3faca 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -2768,7 +2768,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;


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

Reply via email to