Module: sip-router
Branch: master
Commit: 6eccc8b61e848977012d6efa1fb5aae61f8d441e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6eccc8b…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Tue Sep 11 13:05:15 2012 +0100
modules_k/rls: Fixed issues to do with expiry and rls_expires_offset
- These cause particular problems on multi-server systems.
- Found and fixed by Hugh Waite @ Crocodile RCS Ltd
---
modules_k/rls/resource_notify.c | 21 ++++++++-------------
modules_k/rls/subscribe.c | 5 ++++-
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c
index 1fb3de7..e6a0dea 100644
--- a/modules_k/rls/resource_notify.c
+++ b/modules_k/rls/resource_notify.c
@@ -135,15 +135,14 @@ void get_dialog_from_did(char* did, subs_t **dialog, unsigned int
*hash_code)
}
}
- if(*dialog== NULL)
- {
- LM_ERR("while copying subs_t structure\n");
- }
+ if ((*dialog)->expires < (int)time(NULL))
+ (*dialog)->expires = 0;
+ else
+ (*dialog)->expires -= (int)time(NULL);
if (dbmode != RLS_DB_ONLY)
lock_release(&rls_table[*hash_code].lock);
- (*dialog)->expires -= (int)time(NULL);
}
int send_notify(xmlDocPtr * rlmi_doc, char * buf, int buf_len,
@@ -1025,15 +1024,10 @@ static void timer_send_full_state_notifies(int round)
sub.remote_cseq = VAL_INT(&values[rcseq_col]);
sub.status = VAL_INT(&values[status_col]);
sub.version = VAL_INT(&values[version_col]);
- if (VAL_INT(&values[expires_col]) > now)
+ if (VAL_INT(&values[expires_col]) > now + rls_expires_offset)
+ {
sub.expires = VAL_INT(&values[expires_col]) - now;
- else
- sub.expires = 0;
-
- if (sub.expires < rls_expires_offset) sub.expires = 0;
- if (sub.expires != 0)
- {
if (rls_get_service_list(&sub.pres_uri, &sub.watcher_user,
&sub.watcher_domain, &service_node, &doc) < 0)
{
@@ -1057,6 +1051,7 @@ static void timer_send_full_state_notifies(int round)
}
else
{
+ sub.expires = 0;
rls_send_notify(&sub, NULL, NULL, NULL);
delete_rlsdb(&sub.callid, &sub.to_tag, &sub.from_tag);
}
@@ -1185,7 +1180,7 @@ void rls_presentity_clean(unsigned int ticks,void *param)
query_ops[0]= OP_LT;
query_vals[0].nul= 0;
query_vals[0].type= DB1_INT;
- query_vals[0].val.int_val= (int)time(NULL) - 10;
+ query_vals[0].val.int_val= (int)time(NULL) - rls_expires_offset;
if (rlpres_dbf.use_table(rlpres_db, &rlpres_table) < 0)
{
diff --git a/modules_k/rls/subscribe.c b/modules_k/rls/subscribe.c
index c770cbf..441fdd7 100644
--- a/modules_k/rls/subscribe.c
+++ b/modules_k/rls/subscribe.c
@@ -1155,13 +1155,16 @@ void update_a_sub(subs_t *subs_copy)
{
xmlDocPtr doc = NULL;
xmlNodePtr service_node = NULL;
+ int now = (int)time(NULL);
- if ((subs_copy->expires -= (int)time(NULL)) <= 0)
+ if (subs_copy->expires < now)
{
+ subs_copy->expires = 0;
LM_WARN("found expired subscription for: %.*s\n",
subs_copy->pres_uri.len, subs_copy->pres_uri.s);
goto done;
}
+ subs_copy->expires -= now;
if(rls_get_service_list(&subs_copy->pres_uri, &subs_copy->watcher_user,
&subs_copy->watcher_domain, &service_node, &doc)<0)