浏览代码

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
pd 13 年之前
父节点
当前提交
e9e6d51b87
共有 4 个文件被更改,包括 23 次插入0 次删除
  1. 4 0
      modules_k/presence/subscribe.h
  2. 14 0
      modules_k/pua/send_subscribe.c
  3. 1 0
      modules_k/pua/send_subscribe.h
  4. 4 0
      modules_k/rls/subscribe.c

+ 4 - 0
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;
 
 };

+ 14 - 0
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)
 		{

+ 1 - 0
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;
 
 

+ 4 - 0
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");