Module: kamailio
Branch: master
Commit: 3de21172fa0f435a77aea73151a2ddad7a711a8f
URL:
https://github.com/kamailio/kamailio/commit/3de21172fa0f435a77aea73151a2dda…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-01-19T11:05:31+01:00
usrloc: new parameter rm_expired_delay
- set how many seconds to delay the removal of an expired record
- for now works only in DB_ONLY mode
---
Modified: src/modules/usrloc/udomain.c
Modified: src/modules/usrloc/urecord.c
Modified: src/modules/usrloc/usrloc.h
Modified: src/modules/usrloc/usrloc_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/3de21172fa0f435a77aea73151a2dda…
Patch:
https://github.com/kamailio/kamailio/commit/3de21172fa0f435a77aea73151a2dda…
---
diff --git a/src/modules/usrloc/udomain.c b/src/modules/usrloc/udomain.c
index bf4a040e58..a3d948ad0b 100644
--- a/src/modules/usrloc/udomain.c
+++ b/src/modules/usrloc/udomain.c
@@ -42,6 +42,8 @@
#include "usrloc.h"
#include "urecord.h"
+extern int ul_rm_expired_delay;
+
#ifdef STATISTICS
static char *build_stat_name( str* domain, char *var_name)
{
@@ -900,7 +902,7 @@ int db_timer_udomain(udomain_t* _d)
keys[0] = &expires_col;
ops[0] = "<";
vals[0].nul = 0;
- UL_DB_EXPIRES_SET(&vals[0], act_time + 1);
+ UL_DB_EXPIRES_SET(&vals[0], act_time + 1 + ul_rm_expired_delay);
keys[1] = &expires_col;
ops[1] = OP_NEQ;
diff --git a/src/modules/usrloc/urecord.c b/src/modules/usrloc/urecord.c
index ef223db960..482c14efcf 100644
--- a/src/modules/usrloc/urecord.c
+++ b/src/modules/usrloc/urecord.c
@@ -286,8 +286,10 @@ static inline void nodb_timer(urecord_t* _r)
if (!VALID_CONTACT(ptr, act_time)) {
/* run callbacks for EXPIRE event */
- if (exists_ulcb_type(UL_CONTACT_EXPIRE))
+ if (!(ptr->flags&FL_EXPCLB) && exists_ulcb_type(UL_CONTACT_EXPIRE)) {
run_ul_callbacks( UL_CONTACT_EXPIRE, ptr);
+ ptr->flags |= FL_EXPCLB;
+ }
LM_DBG("Binding '%.*s','%.*s' has expired\n",
ptr->aor->len, ZSW(ptr->aor->s),
diff --git a/src/modules/usrloc/usrloc.h b/src/modules/usrloc/usrloc.h
index ef3572262c..6fb4965539 100644
--- a/src/modules/usrloc/usrloc.h
+++ b/src/modules/usrloc/usrloc.h
@@ -62,6 +62,7 @@ typedef enum flags {
FL_NONE = 0, /*!< No flags set */
FL_MEM = 1 << 0, /*!< Update memory only */
FL_DMQRPL = 1 << 1, /*!< DMQ replication */
+ FL_EXPCLB = 1 << 2, /*!< Expired callback executed */
FL_ALL = (int)0xFFFFFFFF /*!< All flags set */
} flags_t;
diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c
index 2eb9037f24..cedc65a73d 100644
--- a/src/modules/usrloc/usrloc_mod.c
+++ b/src/modules/usrloc/usrloc_mod.c
@@ -111,6 +111,7 @@ int ul_keepalive_timeout = 0;
int ul_db_ops_ruid = 1;
int ul_expires_type = 0;
int ul_db_raw_fetch_type = 0;
+int ul_rm_expired_delay = 0;
str ul_xavp_contact_name = {0};
@@ -238,6 +239,7 @@ static param_export_t params[] = {
{"db_insert_null", PARAM_INT, &ul_db_insert_null},
{"server_id_filter", PARAM_INT, &ul_db_srvid},
{"db_timer_clean", PARAM_INT, &ul_db_timer_clean},
+ {"rm_expired_delay", PARAM_INT, &ul_rm_expired_delay},
{0, 0, 0}
};
@@ -272,6 +274,17 @@ static int mod_init(void)
int i;
udomain_t* d;
+ if(ul_rm_expired_delay!=0) {
+ if(db_mode != DB_ONLY) {
+ LM_ERR("rm expired delay feature is available for db only mode\n");
+ return -1;
+ }
+ }
+ if(ul_rm_expired_delay<0) {
+ LM_WARN("rm expired delay value is negative (%d) - setting it to 0\n",
+ ul_rm_expired_delay);
+ ul_rm_expired_delay = 0;
+ }
if(sruid_init(&_ul_sruid, '-', "ulcx", SRUID_INC)<0)
return -1;