Hi Peter,
I noticed a synchronization bug in refresh_watcher() function and I
fixed it. But then I saw that actually this function is not used
inside presence module anymore and does not seem to be exported
either. Do you know of any reason why this function is useful?
Otherwise I will remove it.
Regards,
Anca
On 05/04/2012 11:59 AM, Anca Vamanu wrote:
Module: sip-router
Branch: master
Commit: ca7f45d98faea9479b86e9206c4e2923a009782a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ca7f45d…
Author: Anca Vamanu <anca.vamanu(a)1and1.ro>
Committer: Anca Vamanu <anca.vamanu(a)1and1.ro>
Date: Fri May 4 11:57:27 2012 +0300
modules_k/presence Fixed refresh_watcher function
---
modules_k/presence/subscribe.c | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/modules_k/presence/subscribe.c b/modules_k/presence/subscribe.c
index add1581..ae9e442 100644
--- a/modules_k/presence/subscribe.c
+++ b/modules_k/presence/subscribe.c
@@ -2225,9 +2225,10 @@ int refresh_watcher(str* pres_uri, str* watcher_uri, str* event,
{
unsigned int hash_code;
subs_t* s, *s_copy;
- pres_ev_t* ev;
+ pres_ev_t* ev;
struct sip_uri uri;
str user, domain;
+ subs_t *s_array = NULL;
/* refresh status in subs_htable and send notify */
ev= contains_event(event, NULL);
@@ -2262,28 +2263,43 @@ int refresh_watcher(str* pres_uri, str* watcher_uri, str* event,
s->status= status;
if(reason)
s->reason= *reason;
-
+
s_copy= mem_copy_subs(s, PKG_MEM_TYPE);
if(s_copy== NULL)
{
LM_ERR("copying subs_t\n");
lock_release(&subs_htable[hash_code].lock);
- return -1;
+ goto error;
}
- lock_release(&subs_htable[hash_code].lock);
+
s_copy->local_cseq++;
- if(notify(s_copy, NULL, NULL, 0)< 0)
- {
- LM_ERR("in notify function\n");
- pkg_free(s_copy);
- return -1;
- }
- pkg_free(s_copy);
- lock_get(&subs_htable[hash_code].lock);
+ s_copy->next= s_array;
+ s_array= s_copy;
}
s= s->next;
}
+ lock_release(&subs_htable[hash_code].lock);
+
+ s = s_array;
+ while (s) {
+ if(notify(s, NULL, NULL, 0)< 0) {
+ LM_ERR("Failed to send Notify\n");
+ }
+ s_copy = s;
+ s = s->next;
+ pkg_free(s_copy);
+ }
+
return 0;
+
+error:
+ s = s_array;
+ while (s) {
+ s_copy = s;
+ s = s->next;
+ pkg_free(s_copy);
+ }
+ return -1;
}
int get_db_subs_auth(subs_t* subs, int* found)
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev