Module: kamailio
Branch: 5.4
Commit: 7f14deb8704697ebe1e073c8db30a5569bab6985
URL:
https://github.com/kamailio/kamailio/commit/7f14deb8704697ebe1e073c8db30a55…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-09-23T17:32:17+02:00
usrloc: do keepalive mode checks before expire processing
(cherry picked from commit e67b588434a08c828548c79b6cc5f4c2a7240dc9)
---
Modified: src/modules/usrloc/ul_keepalive.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7f14deb8704697ebe1e073c8db30a55…
Patch:
https://github.com/kamailio/kamailio/commit/7f14deb8704697ebe1e073c8db30a55…
---
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index 105e32a2cf..a1070f3f74 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -126,10 +126,22 @@ int ul_ka_urecord(urecord_t *ur)
if((ul_ka_filter&GAU_OPT_SERVER_ID) && (uc->server_id != server_id)) {
continue;
}
+ if(ul_ka_mode & ULKA_NAT) {
+ /* keepalive for natted contacts only */
+ if (ul_nat_bflag == 0) {
+ continue;
+ }
+ if ((uc->cflags & ul_nat_bflag) != ul_nat_bflag) {
+ continue;
+ }
+ }
+
if(ul_keepalive_timeout>0 && uc->last_keepalive>0) {
if(uc->last_keepalive+ul_keepalive_timeout < tnow) {
/* set contact as expired in 10s */
- LM_DBG("set expired contact on keepalive - aor: %.*s c: %.*s\n",
+ LM_DBG("set expired contact on keepalive (%u + %u < %u)"
+ " - aor: %.*s c: %.*s\n", (unsigned int)uc->last_keepalive,
+ (unsigned int)ul_keepalive_timeout, (unsigned int)tnow,
ur->aor.len, ur->aor.s, uc->c.len, uc->c.s);
if(uc->expires > tnow + 10) {
uc->expires = tnow + 10;
@@ -137,16 +149,6 @@ int ul_ka_urecord(urecord_t *ur)
}
}
}
-
- if(ul_ka_mode & ULKA_NAT) {
- /* keepalive for natted contacts only */
- if (ul_nat_bflag == 0) {
- continue;
- }
- if ((uc->cflags & ul_nat_bflag) != ul_nat_bflag) {
- continue;
- }
- }
if(uc->received.len > 0) {
sdst = uc->received;
} else {