Skip to content

Commit

Permalink
usrloc: new parameter rm_expired_delay
Browse files Browse the repository at this point in the history
- set how many seconds to delay the removal of an expired record
- for now works only in DB_ONLY mode
  • Loading branch information
miconda committed Jan 19, 2018
1 parent 0640853 commit 3de2117
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/modules/usrloc/udomain.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/modules/usrloc/urecord.c
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions src/modules/usrloc/usrloc.h
Expand Up @@ -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;

Expand Down
13 changes: 13 additions & 0 deletions src/modules/usrloc/usrloc_mod.c
Expand Up @@ -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};

Expand Down Expand Up @@ -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}
};

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 3de2117

Please sign in to comment.