Module: kamailio
Branch: master
Commit: b642263a08313e86cc4936a9c489e8afb4a2cb5f
URL:
https://github.com/kamailio/kamailio/commit/b642263a08313e86cc4936a9c489e8a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-07-29T10:54:41+02:00
usrloc: delete contact attributes in db-only mode
---
Modified: src/modules/usrloc/ucontact.h
Modified: src/modules/usrloc/udomain.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b642263a08313e86cc4936a9c489e8a…
Patch:
https://github.com/kamailio/kamailio/commit/b642263a08313e86cc4936a9c489e8a…
---
diff --git a/src/modules/usrloc/ucontact.h b/src/modules/usrloc/ucontact.h
index abe7353ce7..321bd95f7b 100644
--- a/src/modules/usrloc/ucontact.h
+++ b/src/modules/usrloc/ucontact.h
@@ -176,4 +176,6 @@ int uldb_insert_attrs(str *_dname, str *_user, str *_domain,
*/
void ul_set_xavp_contact_clone(int v);
+int uldb_delete_attrs_ruid(str* _dname, str *_ruid);
+
#endif
diff --git a/src/modules/usrloc/udomain.c b/src/modules/usrloc/udomain.c
index c29e6fcfc0..6160cd94b2 100644
--- a/src/modules/usrloc/udomain.c
+++ b/src/modules/usrloc/udomain.c
@@ -909,6 +909,9 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)
int n;
urecord_t* r;
ucontact_t* c;
+#define RUIDBUF_SIZE 128
+ char ruidbuf[RUIDBUF_SIZE];
+ str ruid;
if (db_mode!=DB_ONLY) {
return 0;
@@ -1028,8 +1031,24 @@ int udomain_contact_expired_cb(db1_con_t* _c, udomain_t* _d)
run_ul_callbacks( UL_CONTACT_EXPIRE, c);
}
c->state = CS_SYNC;
+ ruid.len = 0;
+ if(c->ruid.len > 0 && ul_xavp_contact_name.s != NULL) {
+ /* clone ruid to delete attributes out of lock */
+ if(c->ruid.len < RUIDBUF_SIZE - 2) {
+ memcpy(ruidbuf, c->ruid.s, c->ruid.len);
+ ruidbuf[c->ruid.len] = '\0';
+ ruid.s = ruidbuf;
+ ruid.len = c->ruid.len;
+ } else {
+ LM_ERR("ruid is too long: %d\n", c->ruid.len);
+ }
+ }
release_urecord(r);
unlock_udomain(_d, &user);
+ if(ruid.len > 0 && ul_xavp_contact_name.s != NULL) {
+ /* delete attributes by ruid */
+ uldb_delete_attrs_ruid(_d->name, &ruid);
+ }
}
if (DB_CAPABILITY(ul_dbf, DB_CAP_FETCH)) {