Selaa lähdekoodia

usrloc: store keepalive roundtrip in contact structure

Daniel-Constantin Mierla 5 vuotta sitten
vanhempi
commit
68928e95f5
3 muutettua tiedostoa jossa 16 lisäystä ja 5 poistoa
  1. 11 3
      src/modules/usrloc/dlist.c
  2. 1 1
      src/modules/usrloc/ul_keepalive.c
  3. 4 1
      src/modules/usrloc/usrloc.h

+ 11 - 3
src/modules/usrloc/dlist.c

@@ -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

+ 1 - 1
src/modules/usrloc/ul_keepalive.c

@@ -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;
 }

+ 4 - 1
src/modules/usrloc/usrloc.h

@@ -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);