Module: kamailio
Branch: master
Commit: 6b8f6d3b5d563d91234b8d4b7e155b7e74b9d313
URL:
https://github.com/kamailio/kamailio/commit/6b8f6d3b5d563d91234b8d4b7e155b7…
Author: Rick Barenthin <rick(a)ng-voice.com>
Committer: Henning Westerholt <hw(a)gilawa.com>
Date: 2024-05-16T15:18:54+02:00
usrloc: delete location_attrs in db_only mode on delete_urecord
When calling delete_urecord in DB_ONLY mode the location_attrs are not deleted.
This fix makes sure to delete location_attrs when calling db_delete_urecord is called.
---
Modified: src/modules/usrloc/ucontact.c
Modified: src/modules/usrloc/urecord.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6b8f6d3b5d563d91234b8d4b7e155b7…
Patch:
https://github.com/kamailio/kamailio/commit/6b8f6d3b5d563d91234b8d4b7e155b7…
---
diff --git a/src/modules/usrloc/ucontact.c b/src/modules/usrloc/ucontact.c
index f95fe987d75..8a8c1ea7895 100644
--- a/src/modules/usrloc/ucontact.c
+++ b/src/modules/usrloc/ucontact.c
@@ -1784,9 +1784,11 @@ int uldb_delete_attrs(str *_dname, str *_user, str *_domain, str
*_ruid)
str tname;
db_key_t keys[3];
db_val_t vals[3];
+ int n = 0;
- if(ul_db_ops_ruid == 1)
+ if(ul_db_ops_ruid == 1 && _ruid) {
return uldb_delete_attrs_ruid(_dname, _ruid);
+ }
LM_DBG("trying to delete location attributes\n");
@@ -1805,22 +1807,26 @@ int uldb_delete_attrs(str *_dname, str *_user, str *_domain, str
*_ruid)
tname.s = tname_buf;
tname.len = _dname->len + 6;
- keys[0] = &ulattrs_user_col;
- keys[1] = &ulattrs_ruid_col;
- keys[2] = &ulattrs_domain_col;
-
- vals[0].type = DB1_STR;
- vals[0].nul = 0;
- vals[0].val.str_val = *_user;
+ keys[n] = &ulattrs_user_col;
+ vals[n].type = DB1_STR;
+ vals[n].nul = 0;
+ vals[n].val.str_val = *_user;
+ n++;
- vals[1].type = DB1_STR;
- vals[1].nul = 0;
- vals[1].val.str_val = *_ruid;
+ if(_ruid) {
+ keys[n] = &ulattrs_ruid_col;
+ vals[n].type = DB1_STR;
+ vals[n].nul = 0;
+ vals[n].val.str_val = *_ruid;
+ n++;
+ }
if(ul_use_domain) {
- vals[2].type = DB1_STR;
- vals[2].nul = 0;
- vals[2].val.str_val = *_domain;
+ keys[n] = &ulattrs_domain_col;
+ vals[n].type = DB1_STR;
+ vals[n].nul = 0;
+ vals[n].val.str_val = *_domain;
+ n++;
}
if(ul_dbf.use_table(ul_dbh, &tname) < 0) {
@@ -1828,7 +1834,7 @@ int uldb_delete_attrs(str *_dname, str *_user, str *_domain, str
*_ruid)
return -1;
}
- if(ul_dbf.delete(ul_dbh, keys, 0, vals, (ul_use_domain) ? (3) : (2)) < 0) {
+ if(ul_dbf.delete(ul_dbh, keys, 0, vals, n) < 0) {
LM_ERR("deleting from database failed\n");
return -1;
}
diff --git a/src/modules/usrloc/urecord.c b/src/modules/usrloc/urecord.c
index 3c394a24a10..d47167c0f4b 100644
--- a/src/modules/usrloc/urecord.c
+++ b/src/modules/usrloc/urecord.c
@@ -502,6 +502,10 @@ int db_delete_urecord(urecord_t *_r)
vals[1].val.str_val.s = dom + 1;
vals[1].val.str_val.len = _r->aor.s + _r->aor.len - dom - 1;
}
+ uldb_delete_attrs(
+ _r->domain, &vals[0].val.str_val, &vals[1].val.str_val, NULL);
+ } else {
+ uldb_delete_attrs(_r->domain, &vals[0].val.str_val, NULL, NULL);
}
if(ul_dbf.use_table(ul_dbh, _r->domain) < 0) {