Module: kamailio
Branch: master
Commit: 7afe76191e9757770d2933e8c26f305c6ed388a3
URL: 
https://github.com/kamailio/kamailio/commit/7afe76191e9757770d2933e8c26f305c6ed388a3

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2015-05-20T21:44:15+02:00

usrloc: use domain for testing db if use_domain parameter is set

- rework from the patch by Erik Davidson, GH#161

---

Modified: modules/usrloc/udomain.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/7afe76191e9757770d2933e8c26f305c6ed388a3.diff
Patch: 
https://github.com/kamailio/kamailio/commit/7afe76191e9757770d2933e8c26f305c6ed388a3.patch

---

diff --git a/modules/usrloc/udomain.c b/modules/usrloc/udomain.c
index d81e858..2bb1707 100644
--- a/modules/usrloc/udomain.c
+++ b/modules/usrloc/udomain.c
@@ -901,23 +901,30 @@ int db_timer_udomain(udomain_t* _d)
  */
 int testdb_udomain(db1_con_t* con, udomain_t* d)
 {
-       db_key_t key[1], col[1];
-       db_val_t val[1];
+       db_key_t key[2], col[1];
+       db_val_t val[2];
        db1_res_t* res = NULL;
 
-       if (ul_dbf.use_table(con, d->name) < 0) {
+       if(ul_dbf.use_table(con, d->name) < 0) {
                LM_ERR("failed to change table\n");
                return -1;
        }
 
        key[0] = &user_col;
+       key[1] = &domain_col;
 
        col[0] = &user_col;
+
        VAL_TYPE(val) = DB1_STRING;
        VAL_NULL(val) = 0;
        VAL_STRING(val) = "dummy_user";
        
-       if (ul_dbf.query( con, key, 0, val, col, 1, 1, 0, &res) < 0) {
+       VAL_TYPE(val+1) = DB1_STRING;
+       VAL_NULL(val+1) = 0;
+       VAL_STRING(val+1) = "dummy_domain";
+
+       if(ul_dbf.query(con, key, 0, val, col, (use_domain)?2:1, 1, 0, &res)<0) 
{
+               if(res) ul_dbf.free_result( con, res);
                LM_ERR("failure in db_query\n");
                return -1;
        }


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to