ソースを参照

modules/p_usrloc Fixed compilation errors caused by header renaming
Removed use_second_key parameter that has the same meaning like use_domain
Various other small bugfixes

Marius Zbihlei 14 年 前
コミット
168783293b

+ 1 - 1
modules_k/p_usrloc/dlist.c

@@ -46,7 +46,7 @@
 #include "../../socket_info.h"
 #include "../../socket_info.h"
 #include "udomain.h"           /* new_udomain, free_udomain */
 #include "udomain.h"           /* new_udomain, free_udomain */
 #include "utime.h"
 #include "utime.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 #include "ul_db_layer.h"
 #include "ul_db_layer.h"
 
 

+ 10 - 9
modules_k/p_usrloc/p_usrloc_mod.c

@@ -53,7 +53,7 @@
  */
  */
 
 
 #include <stdio.h>
 #include <stdio.h>
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "../../sr_module.h"
 #include "../../sr_module.h"
 #include "../../dprint.h"
 #include "../../dprint.h"
 #include "../../rpc_lookup.h"
 #include "../../rpc_lookup.h"
@@ -106,13 +106,11 @@ extern int ul_locks_no;
 /**
 /**
  * @var params
  * @var params
  * defines the parameters which can be set in the openser config file
  * defines the parameters which can be set in the openser config file
- * is stored. Only used when @see use_second_key is set to 1
+ * is stored. Only used when @see use_domain is set to 1
  * @param write_db_url Url to the database where the key and database information is 
  * @param write_db_url Url to the database where the key and database information is 
  * stored and where errors are reported to. Only used when @see write_on_db is active.
  * stored and where errors are reported to. Only used when @see write_on_db is active.
  * @param read_db_url Url to the database where the key and database information is 
  * @param read_db_url Url to the database where the key and database information is 
  * stored.
  * stored.
- * @param use_second_key specifies if the second key is used for database lookup
- * identification. default is 1 (incactive)
  * @param reg_db_table the name of the table containing the information about the 
  * @param reg_db_table the name of the table containing the information about the 
  * partitioned databases.
  * partitioned databases.
  * @param id_column name of the column containing the id mapping to a key.
  * @param id_column name of the column containing the id mapping to a key.
@@ -136,8 +134,7 @@ extern int ul_locks_no;
  * @param db_retry_interval defines in which intervals the module shall try to 
  * @param db_retry_interval defines in which intervals the module shall try to 
  * reconnect to a deactivated database
  * reconnect to a deactivated database
  * @param write_on_db defines if the module has write access on the databases or not
  * @param write_on_db defines if the module has write access on the databases or not
- * @param alg_location defines the algorithm for the location matching 0 - based on db_location field
- * 1 - based on crc32
+ * @param alg_location defines the algorithm for the location matching - based on crc32 for  now
  */
  */
 
 
 str user_col        = str_init(USER_COL); 		/*!< Name of column containing usernames */
 str user_col        = str_init(USER_COL); 		/*!< Name of column containing usernames */
@@ -156,7 +153,7 @@ str sock_col        = str_init(SOCK_COL);		/*!< Name of column containing the re
 str methods_col     = str_init(METHODS_COL);		/*!< Name of column containing the supported methods */
 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 */
 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 timer_interval  = 60;				/*!< Timer interval in seconds */
-int db_mode         = 0;				/*!< Database sync scheme: 0-no db, 1-write through, 2-write back, 3-only db */
+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 use_domain      = 0;				/*!< Whether usrloc should use domain part of aor */
 int desc_time_order = 0;				/*!< By default do not enable timestamp ordering */
 int desc_time_order = 0;				/*!< By default do not enable timestamp ordering */
 
 
@@ -164,7 +161,6 @@ int ul_fetch_rows = 2000;				/*!< number of rows to fetch from result */
 int ul_hash_size = 9;
 int ul_hash_size = 9;
 str write_db_url         = {DEFAULT_DB_URL, DEFAULT_DB_URL_LEN};
 str write_db_url         = {DEFAULT_DB_URL, DEFAULT_DB_URL_LEN};
 str read_db_url          = {DEFAULT_DB_URL, DEFAULT_DB_URL_LEN};
 str read_db_url          = {DEFAULT_DB_URL, DEFAULT_DB_URL_LEN};
-int use_second_key       = 0;
 str reg_table            = {REG_TABLE, sizeof(REG_TABLE) -1};
 str reg_table            = {REG_TABLE, sizeof(REG_TABLE) -1};
 str id_col               = {ID_COL, sizeof(ID_COL) - 1};
 str id_col               = {ID_COL, sizeof(ID_COL) - 1};
 str url_col              = {URL_COL, sizeof(URL_COL) - 1};
 str url_col              = {URL_COL, sizeof(URL_COL) - 1};
@@ -242,7 +238,6 @@ static param_export_t params[] = {
 	{"domain_db",         STR_PARAM, &domain_db.s         },
 	{"domain_db",         STR_PARAM, &domain_db.s         },
 	{"write_db_url",         STR_PARAM, &write_db_url.s      },
 	{"write_db_url",         STR_PARAM, &write_db_url.s      },
 	{"read_db_url",          STR_PARAM, &read_db_url.s       },
 	{"read_db_url",          STR_PARAM, &read_db_url.s       },
-	{"use_second_key",       INT_PARAM, &use_second_key      },
 	{"reg_db_table",         STR_PARAM, &reg_table.s         },
 	{"reg_db_table",         STR_PARAM, &reg_table.s         },
 	{"id_column",            STR_PARAM, &id_col.s            },
 	{"id_column",            STR_PARAM, &id_col.s            },
 	{"num_column",           STR_PARAM, &num_col.s           },
 	{"num_column",           STR_PARAM, &num_col.s           },
@@ -368,6 +363,7 @@ static int mod_init(void)
 	switch (matching_mode) {
 	switch (matching_mode) {
 		case CONTACT_ONLY:
 		case CONTACT_ONLY:
 		case CONTACT_CALLID:
 		case CONTACT_CALLID:
+		case CONTACT_PATH:
 			break;
 			break;
 		default:
 		default:
 			LM_ERR("invalid matching mode %d\n", matching_mode);
 			LM_ERR("invalid matching mode %d\n", matching_mode);
@@ -388,6 +384,11 @@ static int mod_init(void)
 		return -1;
 		return -1;
 	}
 	}
 
 
+	if (db_mode == NO_DB) {
+		LM_ERR("No database was configured! Partioned user location is useless!");
+		return  -1;
+	}
+
 	/* Shall we use database ? */
 	/* Shall we use database ? */
 	if (db_mode != NO_DB) { /* Yes */
 	if (db_mode != NO_DB) { /* Yes */
 		if(!default_db_url.s || !strlen(default_db_url.s)){
 		if(!default_db_url.s || !strlen(default_db_url.s)){

+ 1 - 2
modules_k/p_usrloc/p_usrloc_mod.h

@@ -74,7 +74,7 @@
 #define DB_DEFAULT_TRANSACTION_LEVEL "READ UNCOMMITED"
 #define DB_DEFAULT_TRANSACTION_LEVEL "READ UNCOMMITED"
 #define DB_DEFAULT_CONNECTION_EXPIRES 300
 #define DB_DEFAULT_CONNECTION_EXPIRES 300
 #define DEFAULT_DB_TYPE "single"
 #define DEFAULT_DB_TYPE "single"
-#define DEFAULT_DOMAIN_DB "location=cluster,cfa=single,cfb=single,cfnr=single,cfnl=single,cfu=single"
+#define DEFAULT_DOMAIN_DB "location=cluster,cfa=single"
 
 
 extern str user_col;
 extern str user_col;
 extern str domain_col;
 extern str domain_col;
@@ -115,7 +115,6 @@ struct mi_root* mi_loc_nr_refresh(struct mi_root* cmd, void* param);
 
 
 extern str write_db_url;
 extern str write_db_url;
 extern str read_db_url;
 extern str read_db_url;
-extern int use_second_key;
 extern str reg_table;
 extern str reg_table;
 extern str id_col;
 extern str id_col;
 extern str url_col;
 extern str url_col;

+ 1 - 1
modules_k/p_usrloc/ucontact.c

@@ -41,7 +41,7 @@
 #include "../../socket_info.h"
 #include "../../socket_info.h"
 #include "../../dprint.h"
 #include "../../dprint.h"
 #include "../../lib/srdb1/db.h"
 #include "../../lib/srdb1/db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "ul_callback.h"
 #include "ul_callback.h"
 #include "urecord.h"
 #include "urecord.h"
 #include "ucontact.h"
 #include "ucontact.h"

+ 1 - 1
modules_k/p_usrloc/udomain.c

@@ -44,7 +44,7 @@
 #include "../../socket_info.h"
 #include "../../socket_info.h"
 #include "../../ut.h"
 #include "../../ut.h"
 #include "../../lib/kcore/hash_func.h"
 #include "../../lib/kcore/hash_func.h"
-#include "ul_mod.h"            /* usrloc module parameters */
+#include "p_usrloc_mod.h"            /* usrloc module parameters */
 #include "utime.h"
 #include "utime.h"
 #include "ul_db_layer.h"
 #include "ul_db_layer.h"
 
 

+ 1 - 1
modules_k/p_usrloc/ul_db.c

@@ -21,7 +21,7 @@
 
 
 #include "../../lib/srdb1/db.h"
 #include "../../lib/srdb1/db.h"
 #include "ul_db.h"
 #include "ul_db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "ul_db_failover.h"
 #include "ul_db_failover.h"
 #include "ul_db_ins.h"
 #include "ul_db_ins.h"
 #include "ul_db_repl.h"
 #include "ul_db_repl.h"

+ 1 - 1
modules_k/p_usrloc/ul_db_failover.c

@@ -23,7 +23,7 @@
 #include "ul_db_failover_func.h"
 #include "ul_db_failover_func.h"
 #include "ul_db_handle.h"
 #include "ul_db_handle.h"
 #include "ul_db.h"
 #include "ul_db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 static ul_db_handle_t spare;
 static ul_db_handle_t spare;
 
 

+ 1 - 1
modules_k/p_usrloc/ul_db_failover_func.c

@@ -22,7 +22,7 @@
 #include "ul_db_failover_func.h"
 #include "ul_db_failover_func.h"
 
 
 #include "../../dprint.h"
 #include "../../dprint.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "ul_db.h"
 #include "ul_db.h"
 
 
 static str autocommit_off = str_init("SET AUTOCOMMIT=0");
 static str autocommit_off = str_init("SET AUTOCOMMIT=0");

+ 1 - 1
modules_k/p_usrloc/ul_db_form_query.c

@@ -22,7 +22,7 @@
 #include "ul_db_form_query.h"
 #include "ul_db_form_query.h"
 #include "ul_db_tran.h"
 #include "ul_db_tran.h"
 #include "ul_db.h"
 #include "ul_db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 static int db_do_query(ul_db_op_t ul_op, db_func_t * dbf, db1_con_t * dbh, str * table, db_key_t* _k, db_op_t* _o,
 static int db_do_query(ul_db_op_t ul_op, db_func_t * dbf, db1_con_t * dbh, str * table, db_key_t* _k, db_op_t* _o,
                        db_val_t* _v, db_key_t* _uk, db_val_t* _uv, int _n, int _un);
                        db_val_t* _v, db_key_t* _uk, db_val_t* _uv, int _n, int _un);

+ 2 - 2
modules_k/p_usrloc/ul_db_handle.c

@@ -20,7 +20,7 @@
  */
  */
 
 
 #include "ul_db_handle.h"
 #include "ul_db_handle.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "ul_db.h"
 #include "ul_db.h"
 #include "ul_db_watch.h"
 #include "ul_db_watch.h"
 #include "../../lib/kcore/km_crc.h"
 #include "../../lib/kcore/km_crc.h"
@@ -531,7 +531,7 @@ static int compute_id(str* first, str* second){
 		return -1;
 		return -1;
 	}
 	}
 	
 	
-	if(use_second_key){
+	if(use_domain){
 		//compute crc32(user@domain)
 		//compute crc32(user@domain)
 		LM_DBG("XDBGX: compute_id HAS second key : %.*s", first->len, first->s);
 		LM_DBG("XDBGX: compute_id HAS second key : %.*s", first->len, first->s);
 		if(!second){
 		if(!second){

+ 1 - 1
modules_k/p_usrloc/ul_db_layer.c

@@ -1,6 +1,6 @@
 #include "../../lib/srdb1/db.h"
 #include "../../lib/srdb1/db.h"
 #include "ul_db.h"
 #include "ul_db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "ul_db_layer.h"
 #include "ul_db_layer.h"
 #include "ul_db_api.h"
 #include "ul_db_api.h"
 
 

+ 1 - 1
modules_k/p_usrloc/ul_db_tran.c

@@ -21,7 +21,7 @@
 
 
 #include "ul_db_tran.h"
 #include "ul_db_tran.h"
 #include "ul_db.h"
 #include "ul_db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 static str autocommit_off = str_init("SET AUTOCOMMIT=0");
 static str autocommit_off = str_init("SET AUTOCOMMIT=0");
 static str start_transaction = str_init("START TRANSACTION");
 static str start_transaction = str_init("START TRANSACTION");

+ 1 - 1
modules_k/p_usrloc/ul_db_watch.c

@@ -24,7 +24,7 @@
 #include "../../sr_module.h"
 #include "../../sr_module.h"
 #include "ul_db_watch.h"
 #include "ul_db_watch.h"
 #include "ul_db.h"
 #include "ul_db.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 typedef struct ul_db_watch_list {
 typedef struct ul_db_watch_list {
 	int id;
 	int id;

+ 1 - 1
modules_k/p_usrloc/ul_mi.c

@@ -42,7 +42,7 @@
 #include "dlist.h"
 #include "dlist.h"
 #include "udomain.h"
 #include "udomain.h"
 #include "utime.h"
 #include "utime.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 
 
 /*! CSEQ nr used */
 /*! CSEQ nr used */

+ 1 - 1
modules_k/p_usrloc/urecord.c

@@ -40,7 +40,7 @@
 #include "../../dprint.h"
 #include "../../dprint.h"
 #include "../../ut.h"
 #include "../../ut.h"
 #include "../../lib/kcore/hash_func.h"
 #include "../../lib/kcore/hash_func.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 #include "utime.h"
 #include "utime.h"
 #include "ul_callback.h"
 #include "ul_callback.h"
 #include "ul_db_layer.h"
 #include "ul_db_layer.h"

+ 1 - 1
modules_k/p_usrloc/usrloc.c

@@ -35,7 +35,7 @@
 
 
 #include "usrloc.h"
 #include "usrloc.h"
 #include "../../sr_module.h"
 #include "../../sr_module.h"
-#include "ul_mod.h"
+#include "p_usrloc_mod.h"
 
 
 /*! nat branch flag */
 /*! nat branch flag */
 extern unsigned int nat_bflag;
 extern unsigned int nat_bflag;