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

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
(cherry picked from commit e9e6d51b87cea0d60c47200ab1f99948b1d9bc48)

- This required a manual merge on a couple of files to get the cherry-pick to 
work

---

 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 bce59b8..f9d72df 100644
--- a/modules_k/pua/send_subscribe.c
+++ b/modules_k/pua/send_subscribe.c
@@ -46,6 +46,7 @@
 #include "send_subscribe.h"
 #include "pua_callback.h"
 #include "event_list.h"
+#include "../presence/subscribe.h"
 
 
 void print_subs(subs_info_t* subs)
@@ -1019,6 +1020,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 e9ae601..e74c69b 100644
--- a/modules_k/rls/subscribe.c
+++ b/modules_k/rls/subscribe.c
@@ -852,6 +852,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)
@@ -993,6 +995,8 @@ int rls_update_subs(struct sip_msg *msg, char *puri, char 
*pevent)
                                        goto loop_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