<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    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 cite="mid:20120504085930.34B55EF804D@rimmer.ryngle.com"
      type="cite">
      <pre wrap="">Module: sip-router
Branch: master
Commit: ca7f45d98faea9479b86e9206c4e2923a009782a
URL:    <a class="moz-txt-link-freetext" 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 class="moz-txt-link-rfc2396E" href="mailto:anca.vamanu@1and1.ro">&lt;anca.vamanu@1and1.ro&gt;</a>
Committer: Anca Vamanu <a class="moz-txt-link-rfc2396E" 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("copying subs_t\n");
                                 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("in notify function\n");
-                                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("Failed to send Notify\n");
+                }
+                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 class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" 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>
  </body>
</html>