[sr-dev] git:master: modules/mtree: when loading data from db, load each tree separately

Juha Heinanen jh at tutpro.com
Wed Oct 30 18:37:38 CET 2013


Module: sip-router
Branch: master
Commit: 6fc84c2cf610791939ba73e38b8b5b3c0b5cd047
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6fc84c2cf610791939ba73e38b8b5b3c0b5cd047

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Wed Oct 30 17:31:04 2013 +0200

modules/mtree: when loading data from db, load each tree separately

---

 modules/mtree/mtree_mod.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/modules/mtree/mtree_mod.c b/modules/mtree/mtree_mod.c
index 0f4348c..eeec89c 100644
--- a/modules/mtree/mtree_mod.c
+++ b/modules/mtree/mtree_mod.c
@@ -291,6 +291,9 @@ static int mod_init(void)
 
 		while(pt!=NULL)
 		{
+		        LM_DBG("loading from tree <%.*s>\n",
+			        pt->tname.len, pt->tname.s);
+
 			/* loading all information from database */
 			if(mt_load_db(&pt->tname)!=0)
 			{
@@ -491,6 +494,9 @@ error:
 static int mt_load_db(str *tname)
 {
 	db_key_t db_cols[3] = {&tprefix_column, &tvalue_column};
+	db_key_t key_cols[1];
+	db_op_t op[1] = {OP_EQ};
+	db_val_t vals[1];
 	str tprefix, tvalue;
 	db1_res_t* db_res = NULL;
 	int i, ret;
@@ -498,6 +504,11 @@ static int mt_load_db(str *tname)
 	m_tree_t *old_tree = NULL; 
 	mt_node_t *bk_head = NULL; 
 
+	key_cols[0] = &tname_column;
+	VAL_TYPE(vals) = DB1_STRING;
+	VAL_NULL(vals) = 0;
+	VAL_STRING(vals) = tname->s;
+
 	if(db_con==NULL)
 	{
 		LM_ERR("no db connection\n");
@@ -521,7 +532,7 @@ static int mt_load_db(str *tname)
 	}
 
 	if (DB_CAPABILITY(mt_dbf, DB_CAP_FETCH)) {
-		if(mt_dbf.query(db_con, 0, 0, 0, db_cols, 0, 2, 0, 0) < 0)
+		if(mt_dbf.query(db_con, key_cols, op, vals, db_cols, 1, 2, 0, 0) < 0)
 		{
 			LM_ERR("Error while querying db\n");
 			return -1;




More information about the sr-dev mailing list