Module: sip-router
Branch: andrei/shm_early_init
Commit: 3d3d38e63a55e549e1707fce0fa1c2c189906338
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3d3d38e…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Sun Jan 10 13:15:57 2010 +0100
NEWS: notes about the shm related changes
---
NEWS | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
index 3cd2de4..225eedc 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,8 @@ config script changes:
- while()
- include file support: include_file "somefile"
- event route support: event_route[module_name:eventid]
+ - user and shm_force_alloc must now appear prior to any modparam() or route
+ block.
build system:
- multiple modules directories are now supported (defined in Makefile.dirs)
@@ -79,6 +81,9 @@ new config variables:
compiled with DBG_QM_MALLOC or DBG_F_MALLOC).
Default: 1.
Can be changed at runtime.
+ - shm = number or shm_mem = number - size of shared memory in MB. It's
+ overwritten if a value is specified on the command line (-m val).
+ Default: 32 Mb. Must appear prior to any modparam() or route block.
new script commands:
add_local_rport() - adds the rport parameter to the added via header
Module: sip-router
Branch: andrei/shm_early_init
Commit: 2c4ae148162c7a36f25d9a7b10fe64c7667ced31
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2c4ae14…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Sun Jan 10 12:50:15 2010 +0100
core: moved shm init into separate files
- shm init moved from main.c into shm_init.c and shm_init.h.
- added a function to check if shm was already intialized
(shm_intialized()).
- make sure the user is set before parsing the config, if present
on the command line (the user is needed to initialize the shared
memory when sysv semaphores are used as the locking method).
---
main.c | 14 ++++++++--
shm_init.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
shm_init.h | 35 ++++++++++++++++++++++++++
3 files changed, 125 insertions(+), 3 deletions(-)
diff --git a/main.c b/main.c
index fd4b642..31a4b65 100644
--- a/main.c
+++ b/main.c
@@ -121,7 +121,8 @@
#include "mem/mem.h"
#ifdef SHM_MEM
#include "mem/shm_mem.h"
-#endif
+#include "shm_init.h"
+#endif /* SHM_MEM */
#include "sr_module.h"
#include "timer.h"
#include "parser/msg_parser.h"
@@ -1720,6 +1721,10 @@ int main(int argc, char** argv)
goto error;
};
break;
+ case 'u':
+ /* user needed for possible shm. pre-init */
+ user=optarg;
+ break;
case 'b':
case 'l':
case 'n':
@@ -1732,7 +1737,6 @@ int main(int argc, char** argv)
case 'W':
case 'w':
case 't':
- case 'u':
case 'g':
case 'P':
case 'G':
@@ -2069,9 +2073,13 @@ try_again:
* -it must be also before init_timer and init_tcp
* -it must be after we know uid (so that in the SYSV sems case,
* the sems will have the correct euid)
+ * Note: shm can now be initialized when parsing the config script, that's
+ * why checking for a prior initialization is needed.
* --andrei */
- if (init_shm_mallocs(shm_force_alloc)==-1)
+#ifdef SHM_MEM
+ if (!shm_initialized() && init_shm()<0)
goto error;
+#endif /* SHM_MEM */
if (init_atomic_ops()==-1)
goto error;
if (init_basex() != 0){
diff --git a/shm_init.c b/shm_init.c
new file mode 100644
index 0000000..d981ae5
--- /dev/null
+++ b/shm_init.c
@@ -0,0 +1,79 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * shm_init.c
+ */
+/*
+ * History:
+ * --------
+ * 2010-01-10 initial version (andrei)
+*/
+
+#include "shm_init.h"
+#include "mem/mem.h"
+#include "globals.h"
+
+static int shm_init = 0;
+
+
+/** check if shm is initialized.
+ * @return 1 if initialized, 0 if not
+ */
+int shm_initialized()
+{
+ return shm_init;
+}
+
+
+
+#ifdef SHM_MEM
+/** init shm mem.
+ * @return 0 on success, < 0 on error
+ * it _must_ be called:
+ * - after the shm_mem_size is known
+ * - after shm_force_alloc is known (mlock_pages should happen at a later
+ * point so it's not yet needed here)
+ * - after the user is known (so that in the SYSV sems case the sems will
+ * have the correct euid)
+ * - before init_timer and init_tcp
+ * --andrei
+ *
+ * Global vars used: shm_mem_size, shm_force_alloc, user & uid.
+ * Side effects: it might set uid, gid and shm_mem_size.
+ */
+int init_shm()
+{
+ /* set uid if user is set */
+ if (user && uid == 0){
+ if (user2uid(&uid, &gid, user)<0){
+ fprintf(stderr, "bad user name/uid number: -u %s\n", user);
+ goto error;
+ }
+ }
+ if (shm_mem_size == 0)
+ shm_mem_size=SHM_MEM_SIZE * 1024 * 1024;
+ if (init_shm_mallocs(shm_force_alloc)==-1)
+ goto error;
+ shm_init=1;
+ return 0;
+error:
+ return -1;
+}
+#endif /* SHM_MEM */
+
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/shm_init.h b/shm_init.h
new file mode 100644
index 0000000..b25ab43
--- /dev/null
+++ b/shm_init.h
@@ -0,0 +1,35 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2010 iptelorg GmbH
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * shm_init.h
+ */
+/*
+ * History:
+ * --------
+ * 2010-01-10 initial version (andrei)
+*/
+
+#ifndef __shm_init_h
+#define __shm_init_h
+
+int shm_initialized();
+int init_shm();
+
+#endif /*__shm_init_h*/
+
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
i am mustafa samara master degree student. i try to test qjsimple
with kamailio openser is it possible (to test the tls support) ?
also i want to ask about ( in sip preferences) what is the deference when we
you use tls as a protocol or when we use (tls or sips) as a SRTP
requirements.
clould you help me please?
i wat to include the result in my thesis
--
Eng.Mustafa Al-Samara
Module: sip-router
Branch: master
Commit: a9b939d7881696aab9d5c39099491e65b4902cee
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9b939d…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Fri Jan 8 18:26:11 2010 +0100
lib/srdb1 (k): add generic helper method for bulk data loading, e.g. for route infos
- add a generic helper method for bulk data loading, e.g. for routing informations
from cr, lcr, htable or other similar tasks
- TODO: adapt cr (patch ready, testing needed), adapt more modules
---
lib/srdb1/db.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/srdb1/db.h | 16 ++++++++++++++++
2 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/lib/srdb1/db.c b/lib/srdb1/db.c
index c4bf7cf..6f85b22 100644
--- a/lib/srdb1/db.c
+++ b/lib/srdb1/db.c
@@ -425,3 +425,55 @@ int db_use_table(db1_con_t* _h, const str* _t)
CON_TABLE(_h) = _t;
return 0;
}
+
+
+/*! \brief Generic query helper for load bulk data
+ *
+ * Generic query helper method for load bulk data, e.g. lcr tables
+ * \param binding database module binding
+ * \param handle database connection
+ * \param name database table name
+ * \param cols queried columns
+ * \param count number of queried columns
+ * \param strict if set to 1 an error is returned when no data could be loaded,
+ otherwise just a warning is logged
+ * \param res database result, unchanged on failure and if no data could be found
+ * \return 0 if the query was run successful, -1 otherwise
+ */
+int db_load_bulk_data(db_func_t* binding, db1_con_t* handle, str* name, db_key_t* cols,
+ unsigned int count, unsigned int strict, db1_res_t* res)
+{
+ if (binding == NULL) {
+ LM_ERR("invalid database module binding\n");
+ return -1;
+ }
+
+ if(handle == NULL) {
+ LM_ERR("invalid database handle\n");
+ return -1;
+ }
+
+ if (binding->use_table(handle, name) < 0) {
+ LM_ERR("error in use_table for database\n");
+ return -1;
+ }
+
+ /* select the whole table and all the columns */
+ if(binding->query(handle, 0, 0, 0, cols, 0, count, 0, &res) < 0) {
+ LM_ERR("error while querying database\n");
+ return -1;
+ }
+
+ if(RES_ROW_N(res) == 0) {
+ binding->free_result(handle, res);
+ if (strict == 1) {
+ LM_ERR("no data in the database table %.*s\n", name->len, name->s);
+ return -1;
+ } else {
+ LM_WARN("no data in the database table %.*s, use an empty set\n", name->len, name->s);
+ return 0;
+ }
+ }
+
+ return 0;
+}
diff --git a/lib/srdb1/db.h b/lib/srdb1/db.h
index 0429e2c..7da401b 100644
--- a/lib/srdb1/db.h
+++ b/lib/srdb1/db.h
@@ -398,5 +398,21 @@ int db_use_table(db1_con_t* _h, const str* _t);
typedef int (*db_bind_api_f)(db_func_t *dbb);
+/**
+ * \brief Generic query helper for load bulk data
+ *
+ * Generic query helper method for load bulk data, e.g. lcr tables
+ * \param binding database module binding
+ * \param handle database connection
+ * \param name database table name
+ * \param cols queried columns
+ * \param count number of queried columns
+ * \param strict if set to 1 an error is returned when no data could be loaded,
+ otherwise just a warning is logged
+ * \param res database result, unchanged on failure and if no data could be found
+ * \return 0 if the query was run successful, -1 otherwise
+ */
+int db_load_bulk_data(db_func_t* binding, db1_con_t* handle, str* name, db_key_t* cols,
+ unsigned int count, unsigned int strict, db1_res_t* res);
#endif /* DB1_H */