Skip to content

Commit

Permalink
usrloc: store keepalive roundtrip in contact structure
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Mar 26, 2020
1 parent 87c5d45 commit 68928e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/modules/usrloc/dlist.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/modules/usrloc/ul_keepalive.c
Expand Up @@ -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;
}
5 changes: 4 additions & 1 deletion src/modules/usrloc/usrloc.h
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 68928e9

Please sign in to comment.