Module: kamailio
Branch: master
Commit: 53ace443020075f7ecd12c72f154193c6cfa6af3
URL:
https://github.com/kamailio/kamailio/commit/53ace443020075f7ecd12c72f154193…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-01-10T12:42:43+01:00
usrloc: added keepalive interval to set the step for sending
- the keepalive is not going to be sent before the interval elapsed
- the keepalive is no longer sent on every timer callback
- default 40 seconds
---
Modified: src/modules/usrloc/ul_keepalive.c
Modified: src/modules/usrloc/usrloc_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/53ace443020075f7ecd12c72f154193…
Patch:
https://github.com/kamailio/kamailio/commit/53ace443020075f7ecd12c72f154193…
---
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index 02c21c0837e..435f84d7c71 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -43,6 +43,7 @@
#include "ul_keepalive.h"
extern int ul_keepalive_timeout;
+extern int ul_ka_interval;
static int ul_ka_send(str *kamsg, dest_info_t *kadst);
@@ -159,6 +160,11 @@ int ul_ka_urecord(urecord_t *ur)
}
}
}
+ if(ul_ka_interval > 0 && uc->last_keepalive > 0
+ && (uc->last_keepalive + ul_ka_interval) < tnow) {
+ /* not yet the time for keepalive */
+ continue;
+ }
if(uc->received.len > 0) {
sdst = uc->received;
} else {
diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c
index e6aa591bbce..f493915a564 100644
--- a/src/modules/usrloc/usrloc_mod.c
+++ b/src/modules/usrloc/usrloc_mod.c
@@ -127,6 +127,7 @@ str ul_ka_domain = str_init("kamailio.org");
str ul_ka_method = str_init("OPTIONS");
int ul_ka_mode = 0;
int ul_ka_filter = 0;
+int ul_ka_interval = 40;
int ul_ka_loglevel = 255;
str ul_ka_logmsg = str_init(" to-uri: [$tu] remote-addr: [$sas]");
pv_elem_t *ul_ka_logfmt = NULL;
@@ -300,6 +301,7 @@ static param_export_t params[] = {
{"ka_domain", PARAM_STR, &ul_ka_domain},
{"ka_method", PARAM_STR, &ul_ka_method},
{"ka_filter", PARAM_INT, &ul_ka_filter},
+ {"ka_interval", PARAM_INT, &ul_ka_interval},
{"ka_timeout", PARAM_INT, &ul_keepalive_timeout},
{"ka_loglevel", PARAM_INT, &ul_ka_loglevel},
{"ka_logmsg", PARAM_STR, &ul_ka_logmsg},