usrloc: store keepalive roundtrip in contact structure
authorDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 26 Mar 2020 20:57:08 +0000 (21:57 +0100)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Thu, 26 Mar 2020 20:57:08 +0000 (21:57 +0100)
src/modules/usrloc/dlist.c
src/modules/usrloc/ul_keepalive.c
src/modules/usrloc/usrloc.h

index a4c838e..11366cc 100644 (file)
@@ -489,11 +489,11 @@ int get_all_ucontacts(void *buf, int len, unsigned int flags,
 }
 
 
-
 /**
  *
  */
-int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
+int ul_update_keepalive(unsigned int _aorhash, str *_ruid, time_t tval,
+               unsigned int rtrip)
 {
        dlist_t *p;
        urecord_t *r;
@@ -523,7 +523,7 @@ int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
                                                        && !memcmp(c->ruid.s, _ruid->s, _ruid->len))
                                        {
                                                /* found */
-                                               c->last_keepalive = time(NULL);
+                                               c->last_keepalive = tval;
                                                LM_DBG("updated keepalive for [%.*s:%u] to %u\n",
                                                                _ruid->len, _ruid->s, _aorhash,
                                                                (unsigned int)c->last_keepalive);
@@ -539,6 +539,14 @@ int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
        return 0;
 }
 
+/**
+ *
+ */
+int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid)
+{
+       return ul_update_keepalive(_aorhash, _ruid, time(NULL), 0);
+}
+
 /*!
  * \brief Create a new domain structure
  * \return 0 if everything went OK, otherwise value < 0 is returned
index 83bce13..b40a930 100644 (file)
@@ -410,7 +410,7 @@ int ul_ka_reply_received(sip_msg_t *msg)
        LM_DBG("reply for keepalive of [%.*s:%u] roundtrip: %u.%06usec\n",
                        ruid.len, ruid.s, aorhash, tvdiff/1000000, tvdiff%1000000);
 
-       ul_refresh_keepalive(aorhash, &ruid);
+       ul_update_keepalive(aorhash, &ruid, tvn.tv_sec, tvdiff);
 
        return 0;
 }
index a1e26da..5d071c1 100644 (file)
@@ -88,7 +88,8 @@ typedef struct ucontact {
        str uniq;               /*!< Uniq header field */
        struct socket_info *sock; /*!< received socket */
        time_t last_modified;   /*!< When the record was last modified */
-       time_t last_keepalive;  /*!< last keepalive timestamp */
+       time_t last_keepalive;  /*!< Last keepalive timestamp */
+       unsigned int ka_roundtrip; /*!< Keepalive roundtrip in microseconds */
        unsigned int methods;   /*!< Supported methods */
        str instance;           /*!< SIP instance value - gruu */
        unsigned int reg_id;    /*!< reg-id parameters */
@@ -192,6 +193,8 @@ int ul_set_keepalive_timeout(int _to);
 typedef int (*ul_refresh_keepalive_t)(unsigned int _aorhash, str *_ruid);
 int ul_refresh_keepalive(unsigned int _aorhash, str *_ruid);
 
+int ul_update_keepalive(unsigned int _aorhash, str *_ruid, time_t tval,
+               unsigned int rtrip);
 
 typedef void (*ul_set_max_partition_t)(unsigned int m);