Module: sip-router
Branch: master
Commit: e9e6d51b87cea0d60c47200ab1f99948b1d9bc48
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e9e6d51b87cea0d60c47200ab1f99948b1d9bc48

Author: pd <[email protected]>
Committer: pd <[email protected]>
Date:   Thu Dec  8 22:01:06 2011 +0000

modules_k/presence, modules_k/pua, modules_k/rls: Changed rls_update_subs() to 
not send unnecessary back-end re-SUBSCRIBEs.

- The initial implementation sent a re-SUBSCRIBE for each existing back-end
  dialog and create new back-end dialogs as required (depending on the contents
  of the updated resource-list) documents.
- This was very wasteful, so this version only sends the new SUBSCRIBEs

---

 modules_k/presence/subscribe.h |    4 ++++
 modules_k/pua/send_subscribe.c |   14 ++++++++++++++
 modules_k/pua/send_subscribe.h |    1 +
 modules_k/rls/subscribe.c      |    4 ++++
 4 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/modules_k/presence/subscribe.h b/modules_k/presence/subscribe.h
index 3e318a1..b216fff 100644
--- a/modules_k/presence/subscribe.h
+++ b/modules_k/presence/subscribe.h
@@ -47,6 +47,9 @@ struct pres_ev;
 #define TERMINATED_STATUS    3
 #define WAITING_STATUS       4
 
+#define INTERNAL_UPDATE_FALSE  0
+#define INTERNAL_UPDATE_TRUE   1
+
 struct subscription
 {
        str pres_uri;
@@ -72,6 +75,7 @@ struct subscription
        int send_on_cback;
        int db_flag;
        str* auth_rules_doc;
+       int internal_update_flag;
        struct subscription* next;
 
 };
diff --git a/modules_k/pua/send_subscribe.c b/modules_k/pua/send_subscribe.c
index 1116896..1406ee4 100644
--- a/modules_k/pua/send_subscribe.c
+++ b/modules_k/pua/send_subscribe.c
@@ -47,6 +47,7 @@
 #include "pua_callback.h"
 #include "event_list.h"
 #include "pua_db.h"
+#include "../presence/subscribe.h"
 
 
 void print_subs(subs_info_t* subs)
@@ -1116,6 +1117,19 @@ insert:
         */
 
                dlg_t* td= NULL;
+
+               if (subs->internal_update_flag == INTERNAL_UPDATE_TRUE)
+               {
+                       LM_INFO("attempting to re-SUBSCRIBE on internal 
(rls_update_subs()) update - skipping\n");
+                       goto done;
+               }
+
+               if (presentity->to_tag.len == 0)
+               {
+                       LM_WARN("attempting to re-SUBSCRIBE to temporary 
(non-established) dialog - skipping\n");
+                       goto done;
+               }
+
                td= pua_build_dlg_t(presentity);
                if(td== NULL)
                {
diff --git a/modules_k/pua/send_subscribe.h b/modules_k/pua/send_subscribe.h
index a6ff737..cddb33a 100644
--- a/modules_k/pua/send_subscribe.h
+++ b/modules_k/pua/send_subscribe.h
@@ -49,6 +49,7 @@ typedef struct subs_info
                                                 for the received reply; it 
must be allocated in share memory;
                                                 a reference to it will be 
found in the cb_param filed of the ua_pres_structure
                                                 receied as a parameter for the 
registered function*/
+       int internal_update_flag;
 }subs_info_t;
 
 
diff --git a/modules_k/rls/subscribe.c b/modules_k/rls/subscribe.c
index cab70ff..5238804 100644
--- a/modules_k/rls/subscribe.c
+++ b/modules_k/rls/subscribe.c
@@ -902,6 +902,8 @@ int resource_subscriptions(subs_t* subs, xmlNodePtr xmlnode)
        extra_headers.len = strlen(extra_headers.s);
 
        s.extra_headers = &extra_headers;
+
+       s.internal_update_flag = subs->internal_update_flag;
        
        if(process_list_and_exec(xmlnode, subs->from_user, subs->from_domain,
                        send_resource_subs, (void*)(&s))<0)
@@ -964,6 +966,8 @@ void update_a_sub(subs_t *subs_copy )
                goto done;
        }
 
+       subs_copy->internal_update_flag = INTERNAL_UPDATE_TRUE;
+
        if(resource_subscriptions(subs_copy, service_node)< 0)
        {
                LM_ERR("failed sending subscribe requests to resources in 
list\n");


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to