Module: kamailio
Branch: master
Commit: f27eda6fe3d99d1352d4df86d79e4646b0a4c17a
URL:
https://github.com/kamailio/kamailio/commit/f27eda6fe3d99d1352d4df86d79e464…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2023-10-19T14:33:45+02:00
presence: active_watcher cleanup timer
related #3074
---
Modified: src/modules/presence/notify.c
Modified: src/modules/presence/notify.h
Modified: src/modules/presence/presence.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f27eda6fe3d99d1352d4df86d79e464…
Patch:
https://github.com/kamailio/kamailio/commit/f27eda6fe3d99d1352d4df86d79e464…
---
diff --git a/src/modules/presence/notify.c b/src/modules/presence/notify.c
index 4edbef12dbe..a3bba03e298 100644
--- a/src/modules/presence/notify.c
+++ b/src/modules/presence/notify.c
@@ -3197,3 +3197,36 @@ void pres_timer_send_notify(unsigned int ticks, void *param)
return;
}
}
+
+void ps_active_watchers_db_timer_clean(unsigned int ticks, void *param)
+{
+ db_key_t db_keys[2];
+ db_val_t db_vals[2];
+ db_op_t db_ops[2];
+
+ if(pa_db == NULL) {
+ return;
+ }
+
+ LM_DBG("cleaning expired active_watchers\n");
+
+ db_keys[0] = &str_expires_col;
+ db_ops[0] = OP_LT;
+ db_vals[0].type = DB1_INT;
+ db_vals[0].nul = 0;
+ db_vals[0].val.int_val = (int)time(NULL);
+
+ db_keys[1] = &str_expires_col;
+ db_ops[1] = OP_GT;
+ db_vals[1].type = DB1_INT;
+ db_vals[1].nul = 0;
+ db_vals[1].val.int_val = 0;
+
+ if(pa_dbf.use_table(pa_db, &active_watchers_table) < 0) {
+ LM_ERR("unsuccessful use table sql operation\n");
+ return;
+ }
+
+ if(pa_dbf.delete(pa_db, db_keys, db_ops, db_vals, 2) < 0)
+ LM_ERR("cleaning expired active_watchers\n");
+}
diff --git a/src/modules/presence/notify.h b/src/modules/presence/notify.h
index 4bac84b481a..3d875f3d452 100644
--- a/src/modules/presence/notify.h
+++ b/src/modules/presence/notify.h
@@ -129,4 +129,5 @@ char *get_status_str(int flag);
str *get_p_notify_body(str pres_uri, pres_ev_t *event, str *etag, str *contact);
void free_notify_body(str *body, pres_ev_t *ev);
void pres_timer_send_notify(unsigned int ticks, void *param);
+void ps_active_watchers_db_timer_clean(unsigned int ticks, void *param);
#endif
diff --git a/src/modules/presence/presence.c b/src/modules/presence/presence.c
index a02c49baf01..93b89fdafa3 100644
--- a/src/modules/presence/presence.c
+++ b/src/modules/presence/presence.c
@@ -453,12 +453,16 @@ static int mod_init(void)
if(pres_timer_mode == 0) {
register_timer(ps_presentity_db_timer_clean, 0, pres_clean_period);
register_timer(ps_watchers_db_timer_clean, 0, pres_clean_period);
+ register_timer(
+ ps_active_watchers_db_timer_clean, 0, pres_clean_period);
if(publ_cache_mode == PS_PCACHE_RECORD) {
register_timer(ps_ptable_timer_clean, 0, pres_clean_period);
}
} else {
sr_wtimer_add(ps_presentity_db_timer_clean, 0, pres_clean_period);
sr_wtimer_add(ps_watchers_db_timer_clean, 0, pres_clean_period);
+ sr_wtimer_add(
+ ps_active_watchers_db_timer_clean, 0, pres_clean_period);
if(publ_cache_mode == PS_PCACHE_RECORD) {
sr_wtimer_add(ps_ptable_timer_clean, 0, pres_clean_period);
}
@@ -1842,6 +1846,7 @@ void rpc_presence_cleanup(rpc_t *rpc, void *c)
(void)ps_watchers_db_timer_clean(0, 0);
(void)ps_presentity_db_timer_clean(0, 0);
+ (void)ps_active_watchers_db_timer_clean(0, 0);
(void)ps_ptable_timer_clean(0, 0);
(void)timer_db_update(0, 0);