Module: sip-router
Branch: 3.3
Commit: cd6dea02f4c8a9aa6c22357f66d4d15713b28797
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cd6dea0…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: Tue Jan 7 14:29:17 2014 +0100
modules_k/usrloc: add user_col to the update contact query with instance
backport of b393656c1113eb3630470389f142c53fbc085a90
---
modules_k/usrloc/ucontact.c | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/modules_k/usrloc/ucontact.c b/modules_k/usrloc/ucontact.c
index 9b21cee..c2462a7 100644
--- a/modules_k/usrloc/ucontact.c
+++ b/modules_k/usrloc/ucontact.c
@@ -752,8 +752,9 @@ int db_update_ucontact(ucontact_t* _c)
*/
int db_update_ucontact_instance(ucontact_t* _c)
{
- db_key_t keys1[2];
- db_val_t vals1[2];
+ char* dom;
+ db_key_t keys1[4];
+ db_val_t vals1[4];
db_key_t keys2[13];
db_val_t vals2[13];
@@ -769,8 +770,9 @@ int db_update_ucontact_instance(ucontact_t* _c)
return -1;
}
- keys1[0] = &instance_col;
- keys1[1] = ®_id_col;
+ keys1[0] = &user_col;
+ keys1[1] = &instance_col;
+ keys1[2] = ®_id_col;
keys2[0] = &expires_col;
keys2[1] = &q_col;
keys2[2] = &cseq_col;
@@ -787,11 +789,15 @@ int db_update_ucontact_instance(ucontact_t* _c)
vals1[0].type = DB1_STR;
vals1[0].nul = 0;
- vals1[0].val.str_val = _c->instance;
+ vals1[0].val.str_val = *_c->aor;
- vals1[1].type = DB1_INT;
+ vals1[1].type = DB1_STR;
vals1[1].nul = 0;
- vals1[1].val.int_val = (int)_c->reg_id;
+ vals1[1].val.str_val = _c->instance;
+
+ vals1[2].type = DB1_INT;
+ vals1[2].nul = 0;
+ vals1[2].val.int_val = (int)_c->reg_id;
vals2[0].type = DB1_DATETIME;
vals2[0].nul = 0;
@@ -870,6 +876,20 @@ int db_update_ucontact_instance(ucontact_t* _c)
vals2[nr_cols2].val.str_val.len = _c->c.len;
nr_cols2++;
+ if (use_domain) {
+ vals1[3].type = DB1_STR;
+ vals1[3].nul = 0;
+ dom = memchr(_c->aor->s, '@', _c->aor->len);
+ if (dom==0) {
+ vals1[0].val.str_val.len = 0;
+ vals1[3].val.str_val = *_c->aor;
+ } else {
+ vals1[0].val.str_val.len = dom - _c->aor->s;
+ vals1[3].val.str_val.s = dom + 1;
+ vals1[3].val.str_val.len = _c->aor->s + _c->aor->len - dom - 1;
+ }
+ }
+
if (ul_dbf.use_table(ul_dbh, _c->domain) < 0) {
LM_ERR("sql use_table failed\n");
return -1;