<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/4.2.3">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#ffffff">
Hi Anca,<BR>
<BR>
I noticed this myself when working on the notify stuff last week.&nbsp; I have no idea what this function does.&nbsp; It appears to be completely unused.<BR>
<BR>
Peter<BR>
<BR>
On Fri, 2012-05-04 at 12:05 +0300, Anca Vamanu wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    Hi Peter,<BR>
    <BR>
    <BR>
    I noticed a synchronization bug in <B>refresh_watcher()</B> 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.<BR>
    <BR>
    <BR>
    Regards,<BR>
    Anca<BR>
    <BR>
    <BR>
    On 05/04/2012 11:59 AM, Anca Vamanu wrote: 
    <BLOCKQUOTE TYPE=CITE>
<PRE>
Module: sip-router
Branch: master
Commit: ca7f45d98faea9479b86e9206c4e2923a009782a
URL:    <A HREF="http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ca7f45d98faea9479b86e9206c4e2923a009782a">http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ca7f45d98faea9479b86e9206c4e2923a009782a</A>

Author: Anca Vamanu <A HREF="mailto:anca.vamanu@1and1.ro">&lt;anca.vamanu@1and1.ro&gt;</A>
Committer: Anca Vamanu <A HREF="mailto:anca.vamanu@1and1.ro">&lt;anca.vamanu@1and1.ro&gt;</A>
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-&gt;status= status;
                         if(reason)
                                 s-&gt;reason= *reason;
-                        
+
                         s_copy= mem_copy_subs(s, PKG_MEM_TYPE);
                         if(s_copy== NULL)
                         {
                                 LM_ERR(&quot;copying subs_t\n&quot;);
                                 lock_release(&amp;subs_htable[hash_code].lock);
-                                return -1;
+                                goto error;
                         }
-                        lock_release(&amp;subs_htable[hash_code].lock);
+
                         s_copy-&gt;local_cseq++;
-                        if(notify(s_copy, NULL, NULL, 0)&lt; 0)
-                        {
-                                LM_ERR(&quot;in notify function\n&quot;);
-                                pkg_free(s_copy);
-                                return -1;
-                        }
-                        pkg_free(s_copy);
-                        lock_get(&amp;subs_htable[hash_code].lock);
+                        s_copy-&gt;next= s_array;
+                        s_array= s_copy;
                 }
                 s= s-&gt;next;
         }
+        lock_release(&amp;subs_htable[hash_code].lock);
+
+        s = s_array;
+        while (s) {
+                if(notify(s, NULL, NULL, 0)&lt; 0) {
+                        LM_ERR(&quot;Failed to send Notify\n&quot;);
+                }
+                s_copy = s;
+                s = s-&gt;next;
+                pkg_free(s_copy);
+        }
+
         return 0;
+
+error:
+        s = s_array;
+        while (s) {
+                s_copy = s;
+                s = s-&gt;next;
+                pkg_free(s_copy);
+        }
+        return -1;
 }
 
 int get_db_subs_auth(subs_t* subs, int* found)


_______________________________________________
sr-dev mailing list
<A HREF="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</A>
<A HREF="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</A>

</PRE>
    </BLOCKQUOTE>
    <BR>
</BLOCKQUOTE>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<PRE>
-- 
Peter Dunkley
Technical Director
Crocodile RCS Ltd
</PRE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>