Module: kamailio
Branch: master
Commit: 6502872d35d9bd7043bf54cd1d640dd64ae87115
URL:
https://github.com/kamailio/kamailio/commit/6502872d35d9bd7043bf54cd1d640dd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-08-28T10:52:55+02:00
usrloc: mark contacts with keepalive sent
- properly detect if the contact record has to be expired or not
---
Modified: src/modules/usrloc/ul_keepalive.c
Modified: src/modules/usrloc/usrloc.h
---
Diff:
https://github.com/kamailio/kamailio/commit/6502872d35d9bd7043bf54cd1d640dd…
Patch:
https://github.com/kamailio/kamailio/commit/6502872d35d9bd7043bf54cd1d640dd…
---
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;