TT#8199 [CARRIER] usrloc: restore use db read-only functionality

we use it just for nathelper pinger.
nathelper "filter_server_id" has to be enabled

Change-Id: If9923b3536874d364ede6656762d238c0df416bb
changes/31/10331/2
Victor Seva 9 years ago
parent c0c3afd401
commit 262ed002a3

@ -17,6 +17,7 @@ sipwise/parallel_build.patch
sipwise/tcap.patch
# carrier support
sipwise/usrloc_dbro.patch
sipwise/usrloc_dbro_pinger.patch
sipwise/0001-kex-add-extended-core-stats.patch
##
sipwise/rtpengine_next_branch_parm.patch

@ -0,0 +1,64 @@
From: Victor Seva <vseva@sipwise.com>
Date: Wed, 21 Dec 2016 09:51:10 +0100
Subject: usrloc: use db_url_ro for pinger from nathelper
get_all_db_ucontacts using db_url_ro if GAU_OPT_SERVER_ID
Change-Id: I9a37aee62c888e72f4d1244db2a22cd412fd800f
---
modules/usrloc/dlist.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c
index 08bc834a..8305328e 100644
--- a/modules/usrloc/dlist.c
+++ b/modules/usrloc/dlist.c
@@ -115,6 +115,8 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
db_op_t ops1[4];
db_key_t keys2[6]; /* select */
int n[2] = {2,6}; /* number of dynamic values used on key1/key2 */
+ db1_con_t* dbh = ul_dbh;
+ db_func_t* dbf = &ul_dbf;
cp = buf;
shortage = 0;
@@ -169,22 +171,26 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
vals1[n[0]].nul = 0;
vals1[n[0]].val.int_val = server_id;
n[0]++;
+ if(ul_dbh_ro) {
+ dbh = ul_dbh_ro;
+ dbf = &ul_dbf_ro;
+ }
}
/* TODO: use part_idx and part_max on keys1 */
for (dom = root; dom!=NULL ; dom=dom->next) {
- if (ul_dbf.use_table(ul_dbh, dom->d->name) < 0) {
+ if (dbf->use_table(dbh, dom->d->name) < 0) {
LM_ERR("sql use_table failed\n");
return -1;
}
- if (ul_dbf.query(ul_dbh, keys1, ops1, vals1, keys2,
+ if (dbf->query(dbh, keys1, ops1, vals1, keys2,
n[0], n[1], NULL, &res) <0 ) {
LM_ERR("query error\n");
return -1;
}
if( RES_ROW_N(res)==0 ) {
- ul_dbf.free_result(ul_dbh, res);
+ dbf->free_result(dbh, res);
continue;
}
@@ -307,7 +313,7 @@ static inline int get_all_db_ucontacts(void *buf, int len, unsigned int flags,
len -= needed;
} /* row cycle */
- ul_dbf.free_result(ul_dbh, res);
+ dbf->free_result(dbh, res);
} /* domain cycle */
/* len < 0 is possible, if size of the buffer < sizeof(c->c.len) */
Loading…
Cancel
Save