tirpi 2009/07/13 17:13:12 CEST
SER CVS Repository
Modified files:
cfg cfg_script.c cfg_struct.c
Log:
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.
Revision Changes Path
1.7 +1 -2 sip_router/cfg/cfg_script.c
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/cfg/cfg_script.c.d…
1.13 +8 -6 sip_router/cfg/cfg_struct.c
http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ser/sip_router/cfg/cfg_struct.c.d…
Module: sip-router
Branch: master
Commit: f38774811308f3e33984fd1e7d1375f00202572f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f387748…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Mon Jul 13 16:58:22 2009 +0200
cfg framework: readme correction
Documentation about how to read "foreign" config values is
corrected.
---
doc/cfg.txt | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/doc/cfg.txt b/doc/cfg.txt
index 93d2c77..548ef5d 100644
--- a/doc/cfg.txt
+++ b/doc/cfg.txt
@@ -169,13 +169,15 @@ cfg_get(foo, cfg_handle, p)
It is also possible to access the variables of other modules or the core in two
different ways:
-1) Include the header file of the other module/core that declares the cfg_group_*
-structure and the handle for it. Than use the handle of that module/core to access
+1) For the core: include the header file that declares the cfg_group_*
+structure and the handle for it. Than use the handle of the core to access
the variable:
-cfg_get(bar, cfg_handle_of_bar, j);
+#include "../../cfg_core.h"
+cfg_get(core, core_cfg, use_dst_blacklist)
-2) Access the variables by their group and variable name:
+2) For the core, module, or script: access the variables by their group
+and variable name:
#include "../../cfg/cfg_select.h"
@@ -195,15 +197,15 @@ static int mod_init(void)
}
int j;
-if ((cfg_read_var_int(&var_bar_j, &j)) < 0) { error... }
+if ((read_cfg_var_int(&var_bar_j, &j)) < 0) { error... }
or similarly,
str s;
-if ((cfg_read_var_str(&var_bar_j, &s)) < 0) { error... }
+if ((read_cfg_var_str(&var_bar_j, &s)) < 0) { error... }
2) is a bit slower than 1) because the first solution returns the pointer directly
-to the variable, but 2) supports also the variables declared in the script that are
-not known at compile time.
+to the variable, but 2) offers access also to the configuration of other modules
+and to the variables declared in the script that are not known at compile time.
3. Using the framework in the core
===============================================================================
Module: sip-router
Branch: master
Commit: df8b1cf011e0ecf4c9f06578ddc6b991fd1444c4
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=df8b1cf…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Mon Jul 13 16:36:36 2009 +0200
cfg framework: fix the group handles in the main process
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_select.c | 9 +++++++++
cfg/cfg_struct.c | 12 +++++++-----
3 files changed, 16 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_select.c b/cfg/cfg_select.c
index 4374aa6..d8871ba 100644
--- a/cfg/cfg_select.c
+++ b/cfg/cfg_select.c
@@ -203,6 +203,10 @@ int select_cfg_var(str *res, select_t *s, struct sip_msg *msg)
/* use the module's handle to access the variable, so the variables
are read from the local config */
p = *(group->handle) + var->offset;
+ if (p == NULL)
+ return -1; /* The group is not yet ready.
+ * (Trying to read the value from the
+ * main process that has no local configuration) */
switch (CFG_VAR_TYPE(var)) {
case CFG_VAR_INT:
@@ -295,9 +299,14 @@ unsigned int read_cfg_var(struct cfg_read_handle *read_handle, void **val)
group = (cfg_group_t *)(read_handle->group);
var = (cfg_mapping_t *)(read_handle->var);
+
/* use the module's handle to access the variable, so the variables
are read from the local config */
p = *(group->handle) + var->offset;
+ if (p == NULL)
+ return 0; /* The group is not yet ready.
+ * (Trying to read the value from the
+ * main process that has no local configuration) */
switch (CFG_VAR_TYPE(var)) {
case CFG_VAR_INT:
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index 533228b..4f28dfe 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 */
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Anonymous user ()
Attached to Project - sip-router
Summary - modules_s/domain should export is_local API function
Task Type - Feature Request
Category - Module
Status - Unconfirmed
Assigned To -
Operating System - All
Severity - Medium
Priority - Normal
Reported Version - Development
Due in Version - Undecided
Due Date - Undecided
Details - In order to replace k domain module with more powerful s domain module, the latter should export is_local API function.
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=9
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.
Revision: 5899
http://openser.svn.sourceforge.net/openser/?rev=5899&view=rev
Author: carstenbock
Date: 2009-07-13 12:40:31 +0000 (Mon, 13 Jul 2009)
Log Message:
-----------
Fix double increase of jiffy-value.
- As noticed by Daniel.
Modified Paths:
--------------
branches/1.5/timer.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Module: sip-router
Branch: master
Commit: 462acb9bf0864bbb18f1a0683869cce8e35aafe0
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=462acb9…
Author: darilion <darilion(a)flunder.lan>
Committer: Klaus Darilion <klaus.mailinglists(a)pernau.at>
Date: Mon Jul 13 13:36:53 2009 +0200
debian: fix rules file
- fix postgress typo
- remove non-existing modules
- fix list of broken modules, and activate it, so that beta-users can make debian packages without errors
---
pkg/debian/rules | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pkg/debian/rules b/pkg/debian/rules
index 999ce8e..289ec3e 100755
--- a/pkg/debian/rules
+++ b/pkg/debian/rules
@@ -36,13 +36,13 @@
export DEB_BUILD_OPTIONS:="$(DEB_BUILD_OPTIONS) nostrip"
# modules not in the "main" ser package
-EXCLUDED_MODULES= jabber xmlrpc postgres cpl cpl-c
+EXCLUDED_MODULES=jabber xmlrpc cpl-c
# extra modules to skip, because they are not compilable now
# - regardless if they go to the main ser package or to some module package,
# they will be excluded from compile and install of all
-#EXTRA_EXCLUDED_MODULES= cpl-c avpops flatstore pdt lcr msilo bdb dbtext iptrtpproxy ldap oracle osp pa rls
-EXTRA_EXCLUDED_MODULES=
+EXTRA_EXCLUDED_MODULES=seas bdb dbtext oracle pa rls iptrtpproxy
+#EXTRA_EXCLUDED_MODULES=
# possible module directories that can appear in MODULES_SP
# (only used for deducing a module name)
@@ -50,7 +50,7 @@ MDIRS=modules modules_s modules_k
# modules packaged in separate packages (complete with full modules_* path)
# with the package name: ser-$(module_name)-module
-MODULES_SP=modules/db_mysql modules/db_postgress modules/tls modules_s/xmlrpc
+MODULES_SP=modules/db_mysql modules/db_postgres modules/tls modules_s/xmlrpc
# module groups that are packaged in seperate packages
# (with the name ser-$(group_name)-modules)