Module: sip-router
Branch: mariuszbihlei/p_usrloc
Commit: 22c89da808874eaa41860766c2781648adfb962e
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=22c89da…
Author: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Committer: Marius Zbihlei <marius.zbihlei(a)1and1.ro>
Date: Mon Jan 24 11:07:04 2011 +0200
Removed timer to delete contacts from db, as this is not supported from p_usrloc.
As documented, the deletion of expired contacts must be done externally
Also, because of the particularities of p_usrloc, only DB_ONLY mode is supported.
(other modes are too centralized and can't scale)
---
modules_k/p_usrloc/README | 15 ++-------------
modules_k/p_usrloc/doc/p_usrloc_user.xml | 25 ++-----------------------
modules_k/p_usrloc/p_usrloc_mod.c | 28 ++--------------------------
modules_k/p_usrloc/p_usrloc_mod.h | 1 -
4 files changed, 6 insertions(+), 63 deletions(-)
diff --git a/modules_k/p_usrloc/README b/modules_k/p_usrloc/README
index b9a235d..de1dddc 100644
--- a/modules_k/p_usrloc/README
+++ b/modules_k/p_usrloc/README
@@ -607,19 +607,8 @@ modparam("p_usrloc", "default_db_url", "mysql://ser:ser@localhost/ser")
5.1. db_mode (integer)
The p_usrloc module must utilize database for persistent contact
- storage. So mode 0 makes no sense in this setup.
- * 1 - Write-Through scheme. All changes to usrloc are immediately
- reflected in database too. This is very slow, but very reliable.
- Use this scheme if speed is not your priority but need to make sure
- that no registered contacts will be lost during crash or reboot.
- * 2 - Write-Back scheme. This is a combination of previous two
- schemes. All changes are made to memory and database
- synchronization is done in the timer. The timer deletes all expired
- contacts and flushes all modified or new contacts to database. Use
- this scheme if you encounter high-load peaks and want them to
- process as fast as possible. The mode will not help at all if the
- load is high all the time. Also, latency of this mode is much lower
- than latency of mode 1, but slightly higher than latency of mode 0.
+ storage. Only mode 3 is possible at this time. Because of the way other
+ matching mode work, they make no sense on a distributed environment.
* 3 - DB-Only scheme. No memory cache is kept, all operations being
directly performed with the database. The timer deletes all expired
contacts from database - cleans after clients that didn't
diff --git a/modules_k/p_usrloc/doc/p_usrloc_user.xml b/modules_k/p_usrloc/doc/p_usrloc_user.xml
index 126aac3..8bc8041 100644
--- a/modules_k/p_usrloc/doc/p_usrloc_user.xml
+++ b/modules_k/p_usrloc/doc/p_usrloc_user.xml
@@ -609,33 +609,12 @@ modparam("p_usrloc", "default_db_url", "mysql://ser:ser@localhost/ser")
<title><varname>db_mode</varname> (integer)</title>
<para>
The p_usrloc module must utilize database for persistent contact storage.
- So mode 0 makes no sense in this setup.
+ Only mode 3 is possible at this time. Because of the way other matching mode work,
+ they make no sense on a distributed environment.
</para>
<itemizedlist>
<listitem>
<para>
- 1 - Write-Through scheme. All changes to usrloc are immediately
- reflected in database too. This is very slow, but very reliable.
- Use this scheme if speed is not your priority but need to make
- sure that no registered contacts will be lost during crash or
- reboot.
- </para>
- </listitem>
- <listitem>
- <para>
- 2 - Write-Back scheme. This is a combination of previous two
- schemes. All changes are made to memory and database
- synchronization is done in the timer. The timer deletes all
- expired contacts and flushes all modified or new contacts to
- database. Use this scheme if you encounter high-load peaks
- and want them to process as fast as possible. The mode will
- not help at all if the load is high all the time. Also, latency
- of this mode is much lower than latency of mode 1, but slightly
- higher than latency of mode 0.
- </para>
- </listitem>
- <listitem>
- <para>
3 - DB-Only scheme. No memory cache is kept, all operations being
directly performed with the database. The timer deletes all
expired contacts from database - cleans after clients that didn't
diff --git a/modules_k/p_usrloc/p_usrloc_mod.c b/modules_k/p_usrloc/p_usrloc_mod.c
index 4eaef74..6c8c76a 100644
--- a/modules_k/p_usrloc/p_usrloc_mod.c
+++ b/modules_k/p_usrloc/p_usrloc_mod.c
@@ -57,7 +57,6 @@
#include "../../sr_module.h"
#include "../../dprint.h"
#include "../../rpc_lookup.h"
-#include "../../timer.h" /* register_timer */
#include "../../globals.h" /* is_main */
#include "../../ut.h" /* str_init */
#include "udomain.h" /* {insert,delete,get,release}_urecord */
@@ -92,7 +91,6 @@ MODULE_VERSION
static int mod_init(void); /*!< Module initialization function */
static void destroy(void); /*!< Module destroy function */
-static void timer(unsigned int ticks, void* param); /*!< Timer handler */
static int child_init(int rank); /*!< Per-child init function */
static int mi_child_init(void);
static int mi_child_loc_nr_init(void);
@@ -151,7 +149,6 @@ str path_col = str_init(PATH_COL); /*!< Name of column containing the Pa
str sock_col = str_init(SOCK_COL); /*!< Name of column containing the received socket */
str methods_col = str_init(METHODS_COL); /*!< Name of column containing the supported methods */
str last_mod_col = str_init(LAST_MOD_COL); /*!< Name of column containing the last modified date */
-int timer_interval = 60; /*!< Timer interval in seconds */
int db_mode = 3; /*!< Database sync scheme: 1-write through, 2-write back, 3-only db */
int use_domain = 0; /*!< Whether usrloc should use domain part of aor */
int desc_time_order = 0; /*!< By default do not enable timestamp ordering */
@@ -218,7 +215,6 @@ static param_export_t params[] = {
{"cseq_column", STR_PARAM, &cseq_col.s },
{"flags_column", STR_PARAM, &flags_col.s },
{"cflags_column", STR_PARAM, &cflags_col.s },
- {"timer_interval", INT_PARAM, &timer_interval },
{"db_mode", INT_PARAM, &db_mode },
{"use_domain", INT_PARAM, &use_domain },
{"desc_time_order", INT_PARAM, &desc_time_order },
@@ -374,24 +370,17 @@ static int mod_init(void)
return -1;
}
- /* Register cache timer */
- register_timer( timer, 0, timer_interval);
-
/* init the callbacks list */
if ( init_ulcb_list() < 0) {
LM_ERR("usrloc/callbacks initialization failed\n");
return -1;
}
- if (db_mode == NO_DB) {
- LM_ERR("No database was configured! Partioned user location is useless!");
+ if (db_mode != DB_ONLY) {
+ LM_ERR("DB_ONLY is the only mode possible for partitioned usrloc. Please set db_mode to 3");
return -1;
}
- if (db_mode == WRITE_BACK) {
- LM_WARN("The WRITE BACK mode will create discrepancies between memory and db backend");
- }
-
/* Shall we use database ? */
if (db_mode != NO_DB) { /* Yes */
if(!default_db_url.s || !strlen(default_db_url.s)){
@@ -481,9 +470,6 @@ static void destroy(void)
{
/* we need to sync DB in order to flush the cache */
ul_unlock_locks();
- if (synchronize_all_udomains() != 0) {
- LM_ERR("flushing cache failed\n");
- }
free_all_udomains();
ul_destroy_locks();
@@ -497,16 +483,6 @@ static void destroy(void)
}
-/*! \brief
- * Timer handler
- */
-static void timer(unsigned int ticks, void* param)
-{
- if (synchronize_all_udomains() != 0) {
- LM_ERR("synchronizing cache failed\n");
- }
-}
-
static int mi_child_loc_nr_init(void)
{
if(ul_db_child_locnr_init() < 0){
diff --git a/modules_k/p_usrloc/p_usrloc_mod.h b/modules_k/p_usrloc/p_usrloc_mod.h
index dd893e5..bba2e46 100644
--- a/modules_k/p_usrloc/p_usrloc_mod.h
+++ b/modules_k/p_usrloc/p_usrloc_mod.h
@@ -87,7 +87,6 @@ extern str sock_col;
extern str methods_col;
extern str last_mod_col;
-extern int timer_interval;
extern int db_mode;
extern int use_domain;
extern int desc_time_order;