Module: sip-router
Branch: master
Commit: b393656c1113eb3630470389f142c53fbc085a90
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b393656…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: Tue Jan 7 13:59:37 2014 +0100
usrloc: add user_col to the update contact query with instance
---
modules/usrloc/ucontact.c | 48 ++++++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c
index 4877c7f..b18ce98 100644
--- a/modules/usrloc/ucontact.c
+++ b/modules/usrloc/ucontact.c
@@ -1051,8 +1051,8 @@ int db_update_ucontact_instance(ucontact_t* _c)
{
str auser;
str adomain;
- db_key_t keys1[2];
- db_val_t vals1[2];
+ db_key_t keys1[4];
+ db_val_t vals1[4];
int n1;
db_key_t keys2[13];
@@ -1070,6 +1070,13 @@ int db_update_ucontact_instance(ucontact_t* _c)
}
n1 = 0;
+ keys1[n1] = &user_col;
+ vals1[n1].type = DB1_STR;
+ vals1[n1].nul = 0;
+ vals1[n1].val.str_val = *_c->aor;
+ LM_DBG("aor:%.*s\n", vals1[n1].val.str_val.len, vals1[n1].val.str_val.s);
+ n1++;
+
keys1[n1] = &instance_col;
vals1[n1].type = DB1_STR;
vals1[n1].nul = 0;
@@ -1181,6 +1188,29 @@ int db_update_ucontact_instance(ucontact_t* _c)
LM_DBG("contact:%.*s\n", vals2[n2].val.str_val.len, vals2[n2].val.str_val.s);
n2++;
+ auser = *_c->aor;
+ if (use_domain) {
+ keys1[n1] = &domain_col;
+ vals1[n1].type = DB1_STR;
+ vals1[n1].nul = 0;
+ adomain.s = memchr(_c->aor->s, '@', _c->aor->len);
+ if (adomain.s==0) {
+ vals1[0].val.str_val.len = 0;
+ vals1[n1].val.str_val = *_c->aor;
+ auser.len = 0;
+ adomain = *_c->aor;
+ } else {
+ vals1[0].val.str_val.len = adomain.s - _c->aor->s;
+ vals1[n1].val.str_val.s = adomain.s + 1;
+ vals1[n1].val.str_val.len = _c->aor->s + _c->aor->len - adomain.s - 1;
+ auser.len = adomain.s - _c->aor->s;
+ adomain.s++;
+ adomain.len = _c->aor->s +
+ _c->aor->len - adomain.s;
+ }
+ n1++;
+ }
+
if (ul_dbf.use_table(ul_dbh, _c->domain) < 0) {
LM_ERR("sql use_table failed\n");
return -1;
@@ -1204,19 +1234,7 @@ int db_update_ucontact_instance(ucontact_t* _c)
/* delete old db attrs and add the current list */
if (ul_xavp_contact_name.s) {
- auser = *_c->aor;
- if (use_domain) {
- adomain.s = memchr(_c->aor->s, '@', _c->aor->len);
- if (adomain.s==0) {
- auser.len = 0;
- adomain = *_c->aor;
- } else {
- auser.len = adomain.s - _c->aor->s;
- adomain.s++;
- adomain.len = _c->aor->s +
- _c->aor->len - adomain.s;
- }
-
+ if (use_domain) {
uldb_delete_attrs(_c->domain, &auser,
&adomain, &_c->ruid);
uldb_insert_attrs(_c->domain, &auser,