Module: sip-router
Branch: master
Commit: 83cdd718fab4e244c5362df5102481ce32f75ae1
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=83cdd71…
Author: Juha Heinanen <jh(a)tutpro.com>
Committer: Juha Heinanen <jh(a)tutpro.com>
Date: Thu Sep 27 19:16:47 2012 +0300
modules_k/pua: always use_table before making db queries
---
modules_k/pua/pua.c | 2 +-
modules_k/pua/pua.h | 1 +
modules_k/pua/pua_db.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 77 insertions(+), 2 deletions(-)
diff --git a/modules_k/pua/pua.c b/modules_k/pua/pua.c
index 8734d35..900e582 100644
--- a/modules_k/pua/pua.c
+++ b/modules_k/pua/pua.c
@@ -63,7 +63,7 @@ extern int bind_pua(pua_api_t* api);
int min_expires= 0;
int default_expires=3600;
static str db_url = str_init(DEFAULT_DB_URL);
-static str db_table= str_init("pua");
+str db_table= str_init("pua");
int update_period= 100;
str outbound_proxy = {0, 0};
int check_remote_contact = 1;
diff --git a/modules_k/pua/pua.h b/modules_k/pua/pua.h
index 34e2135..eef362f 100644
--- a/modules_k/pua/pua.h
+++ b/modules_k/pua/pua.h
@@ -59,5 +59,6 @@ extern db_func_t pua_dbf;
extern db1_con_t *pua_db;
extern int pua_fetch_rows;
+extern str db_table;
#endif
diff --git a/modules_k/pua/pua_db.c b/modules_k/pua/pua_db.c
index 8d72a96..b37fed2 100644
--- a/modules_k/pua/pua_db.c
+++ b/modules_k/pua/pua_db.c
@@ -168,6 +168,11 @@ int clean_puadb( int update_period, int min_expires )
q_vals[0].val.int_val = now+update_period;
q_ops[0] = OP_LT;
+ if (pua_dbf.use_table(pua_db, &db_table) < 0) {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if(db_fetch_query(&pua_dbf, pua_fetch_rows, pua_db, q_cols, q_ops,
q_vals, NULL, 1, 0, 0, &res) < 0)
{
@@ -279,6 +284,11 @@ int is_dialog_puadb(ua_pres_t *pres)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
if(pua_dbf.query(pua_db, q_cols, 0, q_vals,
res_cols,n_query_cols,n_res_cols,0,&res) < 0)
@@ -367,6 +377,12 @@ int get_record_id_puadb(ua_pres_t *pres, str **rec_id )
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if(pua_dbf.query(pua_db, q_cols, 0, q_vals,
res_cols,n_query_cols,n_res_cols,0,&res) < 0)
{
@@ -614,7 +630,11 @@ int convert_temporary_dialog_puadb(ua_pres_t *pres)
query_vals[n_query_cols].val.str_val.len = 0;
n_query_cols++;
-
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
if (pua_dbf.replace != NULL)
{
@@ -843,6 +863,12 @@ ua_pres_t *get_record_puadb(str pres_id, str *etag, ua_pres_t
*result, db1_res_t
return(NULL);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(NULL);
+ }
+
if(query_fn(pua_db, q_cols, 0, q_vals,
NULL,n_query_cols,0,0,&res) < 0)
{
@@ -919,6 +945,12 @@ int delete_record_puadb(ua_pres_t *pres)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0)
{
LM_ERR("deleting record\n");
@@ -985,6 +1017,12 @@ int update_record_puadb(ua_pres_t *pres, int expires, str *etag)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if (pua_dbf.update(pua_db, q_cols, 0, q_vals, u_cols, u_vals,
n_query_cols, n_update_cols) < 0)
{
@@ -1192,6 +1230,12 @@ ua_pres_t *get_dialog_puadb(str pres_id, str *pres_uri, ua_pres_t
*result, db1_r
return(NULL);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(NULL);
+ }
+
if(query_fn(pua_db, q_cols, 0, q_vals,
NULL,n_query_cols,0,0,&res) < 0)
{
@@ -1278,6 +1322,12 @@ int delete_dialog_puadb(ua_pres_t *pres)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0)
{
LM_ERR("deleting record\n");
@@ -1350,6 +1400,12 @@ int update_dialog_puadb(ua_pres_t *pres, int expires, str
*contact)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if (pua_dbf.update(pua_db, q_cols, 0, q_vals, u_cols, u_vals,
n_query_cols, n_update_cols) < 0)
{
@@ -1409,6 +1465,12 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if(pua_dbf.update(pua_db, q_cols, 0, q_vals,
db_cols,db_vals,n_query_cols,n_update_cols) < 0)
{
@@ -1467,6 +1529,12 @@ int update_version_puadb(ua_pres_t *pres)
return(-1);
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(-1);
+ }
+
if(pua_dbf.update(pua_db, q_cols, 0, q_vals,
db_cols,db_vals,n_query_cols,n_update_cols) < 0)
@@ -1505,6 +1573,12 @@ list_entry_t *get_subs_list_puadb(str *did)
return list;
}
+ if (pua_dbf.use_table(pua_db, &db_table) < 0)
+ {
+ LM_ERR("error in use_table pua\n");
+ return(list);
+ }
+
if(db_fetch_query(&pua_dbf, pua_fetch_rows, pua_db, q_cols, 0,
q_vals, res_cols, n_query_cols, n_res_cols, 0, &res) < 0)
{