Module: kamailio
Branch: 5.8
Commit: 661b2670168530c21ee4dd23fcb29abf8b5bc3ba
URL:
https://github.com/kamailio/kamailio/commit/661b2670168530c21ee4dd23fcb29ab…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-09-02T09:37:04+02:00
usrloc: mark contacts with keepalive sent
- properly detect if the contact record has to be expired or not
(cherry picked from commit 6502872d35d9bd7043bf54cd1d640dd64ae87115)
---
Modified: src/modules/usrloc/ul_keepalive.c
Modified: src/modules/usrloc/usrloc.h
---
Diff:
https://github.com/kamailio/kamailio/commit/661b2670168530c21ee4dd23fcb29ab…
Patch:
https://github.com/kamailio/kamailio/commit/661b2670168530c21ee4dd23fcb29ab…
---
diff --git a/src/modules/usrloc/ul_keepalive.c b/src/modules/usrloc/ul_keepalive.c
index e5a013b45a3..16fb66021c1 100644
--- a/src/modules/usrloc/ul_keepalive.c
+++ b/src/modules/usrloc/ul_keepalive.c
@@ -148,7 +148,8 @@ int ul_ka_urecord(urecord_t *ur)
}
}
- if(ul_keepalive_timeout > 0 && uc->last_keepalive > 0) {
+ if(ul_keepalive_timeout > 0 && uc->last_keepalive > 0
+ && (uc->flags & FL_KASENT)) {
if(uc->last_keepalive + ul_keepalive_timeout < tnow) {
/* set contact as expired in 10s */
LM_DBG("set expired contact on keepalive (%u + %u < %u)"
@@ -257,7 +258,9 @@ int ul_ka_urecord(urecord_t *ur)
kabuf_len, kabuf);
kamsg.s = kabuf;
kamsg.len = kabuf_len;
- ul_ka_send(&kamsg, &idst);
+ if(ul_ka_send(&kamsg, &idst) >= 0) {
+ uc->flags |= FL_KASENT;
+ }
}
}
return 0;
diff --git a/src/modules/usrloc/usrloc.h b/src/modules/usrloc/usrloc.h
index 54f7986080d..370baf0da86 100644
--- a/src/modules/usrloc/usrloc.h
+++ b/src/modules/usrloc/usrloc.h
@@ -63,6 +63,7 @@ typedef enum flags
FL_MEM = 1 << 0, /*!< Update memory only */
FL_DMQRPL = 1 << 1, /*!< DMQ replication */
FL_EXPCLB = 1 << 2, /*!< Expired callback executed */
+ FL_KASENT = 1 << 3, /*!< Keepalive sent to contact */
FL_ALL = (int)0xFFFFFFFF /*!< All flags set */
} flags_t;