Module: sip-router
Branch: ser_core_cvs
Commit: c0f12714391fa6b359cceaed22ed238ba5387457
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c0f1271…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Mon Jul 13 15:13:12 2009 +0000
cfg framework: fix the group handles in the main process
(backport from GIT)
The main process does not have a local configuration,
it has access only to the config values that were set before
forking. As a result, the group handles cannot ponint to
the shared memory address because the shared memory block
may be freed later by one of the child processes. This problem
resulted sometimes in a core dump after the processes were killed
when the main process tried to access a variable from shared mem
which was no longer available.
---
cfg/cfg_script.c | 1 -
cfg/cfg_struct.c | 12 +++++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/cfg/cfg_script.c b/cfg/cfg_script.c
index 39a4068..8804e40 100644
--- a/cfg/cfg_script.c
+++ b/cfg/cfg_script.c
@@ -143,7 +143,6 @@ error:
/* fix-up the dynamically declared group:
* - allocate memory for the arrays
* - set the values within the memory block
- * - notify the drivers about the new group
*/
int cfg_script_fixup(cfg_group_t *group, unsigned char *block)
{
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index fe7d8d6..966443e 100644
--- a/cfg/cfg_struct.c
+++ b/cfg/cfg_struct.c
@@ -194,21 +194,23 @@ int cfg_shmize(void)
/* clone the strings to shm mem */
if (cfg_shmize_strings(group)) goto error;
- /* copy the values to the new block,
- and update the module's handle */
+ /* copy the values to the new block */
memcpy(block->vars+group->offset, group->vars, group->size);
- *(group->handle) = block->vars+group->offset;
} else {
/* The group was declared with NULL values,
* we have to fix it up.
* The fixup function takes care about the values,
* it fills up the block */
if (cfg_script_fixup(group, block->vars+group->offset)) goto error;
- *(group->handle) = block->vars+group->offset;
- /* notify the drivers about the new config definition */
+ /* Notify the drivers about the new config definition.
+ * Temporary set the group handle so that the drivers have a chance to
+ * overwrite the default values. The handle must be reset after this
+ * because the main process does not have a local configuration. */
+ *(group->handle) = block->vars+group->offset;
cfg_notify_drivers(group->name, group->name_len,
group->mapping->def);
+ *(group->handle) = NULL;
}
}
/* try to fixup the selects that failed to be fixed-up previously */
Module: sip-router
Branch: master
Commit: dba9e85e137cc3818a01cccb2930e7580564ecd1
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dba9e85…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Jul 17 17:10:07 2009 +0200
core: expr =~ fixup order fix
The fixup for built-in expressions were in the wrong order: first
RE and then RVE/RVALs, but a RVE/RVALs could be optimized away to
a string => because of the wrong order at runtime the match
operator might end up being used with a normal string instead of a
RE.
Now the order is RVE/RVALs fixup & optimisations, string fixups
(len) and then RE fixups (so that by the time the RE fixup is run
we know the final type of its operand).
Reported-by: Nils Ohlmeier nils at iptel org
---
route.c | 66 +++++++++++++++++++++++++++++++++-----------------------------
1 files changed, 35 insertions(+), 31 deletions(-)
diff --git a/route.c b/route.c
index e22820d..effb608 100644
--- a/route.c
+++ b/route.c
@@ -525,6 +525,41 @@ int fix_expr(struct expr* exp)
exp->op);
}
}else if (exp->type==ELEM_T){
+ /* first fix & optimize rve/rvals (they might be optimized
+ to non-rvals, e.g. string, avp a.s.o) */
+ if (exp->l_type==RVEXP_O){
+ if ((ret=fix_rval_expr(&exp->l.param))<0){
+ ERR("Unable to fix left rval expression\n");
+ return ret;
+ }
+ if (scr_opt_lev>=2)
+ exp_optimize_left(exp);
+ }
+ if (exp->r_type==RVE_ST){
+ if ((ret=fix_rval_expr(&exp->r.param))<0){
+ ERR("Unable to fix right rval expression\n");
+ return ret;
+ }
+ if (scr_opt_lev>=2)
+ exp_optimize_right(exp);
+ }
+
+ /* Calculate lengths of strings */
+ if (exp->l_type==STRING_ST) {
+ int len;
+ if (exp->l.string) len = strlen(exp->l.string);
+ else len = 0;
+ exp->l.str.s = exp->l.string;
+ exp->l.str.len = len;
+ }
+ if (exp->r_type==STRING_ST) {
+ int len;
+ if (exp->r.string) len = strlen(exp->r.string);
+ else len = 0;
+ exp->r.str.s = exp->r.string;
+ exp->r.str.len = len;
+ }
+
if (exp->op==MATCH_OP){
/* right side either has to be string, in which case
* we turn it into regular expression, or it is regular
@@ -562,21 +597,6 @@ int fix_expr(struct expr* exp)
return ret;
}
}
- /* Calculate lengths of strings */
- if (exp->l_type==STRING_ST) {
- int len;
- if (exp->l.string) len = strlen(exp->l.string);
- else len = 0;
- exp->l.str.s = exp->l.string;
- exp->l.str.len = len;
- }
- if (exp->r_type==STRING_ST) {
- int len;
- if (exp->r.string) len = strlen(exp->r.string);
- else len = 0;
- exp->r.str.s = exp->r.string;
- exp->r.str.len = len;
- }
if (exp->l_type==SELECT_O) {
if ((ret=resolve_select(exp->l.select)) < 0) {
BUG("Unable to resolve select\n");
@@ -591,22 +611,6 @@ int fix_expr(struct expr* exp)
return ret;
}
}
- if (exp->l_type==RVEXP_O){
- if ((ret=fix_rval_expr(&exp->l.param))<0){
- ERR("Unable to fix left rval expression\n");
- return ret;
- }
- if (scr_opt_lev>=2)
- exp_optimize_left(exp);
- }
- if (exp->r_type==RVE_ST){
- if ((ret=fix_rval_expr(&exp->r.param))<0){
- ERR("Unable to fix right rval expression\n");
- return ret;
- }
- if (scr_opt_lev>=2)
- exp_optimize_right(exp);
- }
/* PVAR don't need fixing */
ret=0;
}
andrei 2009/07/17 15:37:11 CEST
SER CVS Repository
Modified files:
. cfg.lex cfg.y
Log:
core: config parser listen if names fix
If no quotes were used in listen=x, it was assumed that x was an
ip or a valid hostname (each domain part starts with a letter,
numbers and '_' are not allowed as first chars). However this
assumption failed when interface names were used, e.g. eth0.1 is a
valid interface name, but listen=eth0.1 resulted in error (it
worked only if quotes were used, e.g. listen="eth0.1").
Revision Changes Path
1.126 +30 -13 sip_router/cfg.lex
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/cfg.lex.diff?r1=1.…
1.184 +36 -4 sip_router/cfg.y
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/cfg.y.diff?r1=1.18…
andrei 2009/07/17 15:37:02 CEST
SER CVS Repository
Modified files:
. cfg.y
Log:
core: config parser listen fix
- do not crash when the listen=host line contains an invalid host (e.g. foo.1)
- more null checks
Reported-by: Cristian Constantin cristian.constantin at iptel org
Revision Changes Path
1.183 +45 -32 sip_router/cfg.y
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/cfg.y.diff?r1=1.18…