[svn-commits] mmichelson: branch mmichelson/pub_sub r385786 - /team/mmichelson/pub_sub/res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Apr 15 13:02:54 CDT 2013


Author: mmichelson
Date: Mon Apr 15 13:02:52 2013
New Revision: 385786

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385786
Log:
Switch mwi_subscriptions container to be an ao2 global object.

This is the first step towards writing an easy method for doing reloads.
Taking it one step at a time should ensure I don't screw things up too badly.


Modified:
    team/mmichelson/pub_sub/res/res_sip_mwi.c

Modified: team/mmichelson/pub_sub/res/res_sip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pub_sub/res/res_sip_mwi.c?view=diff&rev=385786&r1=385785&r2=385786
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_mwi.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_mwi.c Mon Apr 15 13:02:52 2013
@@ -38,8 +38,8 @@
 	<support_level>core</support_level>
  ***/
 
-struct ao2_container *mwi_subscriptions;
 struct mwi_subscription;
+AO2_GLOBAL_OBJ_STATIC(unsolicited_mwi);
 
 #define STASIS_BUCKETS 13
 #define MWI_BUCKETS 53
@@ -373,7 +373,6 @@
 			ao2_link(sub->stasis_subs, mwi_stasis_sub);
 		}
 	}
-	ao2_link(mwi_subscriptions, sub);
 
 	evsub = ast_sip_subscription_get_evsub(sub->sip_sub);
 	pjsip_evsub_accept(evsub, rdata, 200, NULL);
@@ -468,6 +467,7 @@
 {
 	RAII_VAR(struct mwi_subscription *, aggregate_sub, NULL, ao2_cleanup);
 	struct ast_sip_endpoint *endpoint = obj;
+	struct ao2_container *mwi_subscriptions = arg;
 	char *mailboxes;
 	char *mailbox;
 
@@ -505,21 +505,23 @@
 
 static void create_mwi_subscriptions(void)
 {
+	struct ao2_container *mwi_subscriptions = ao2_container_alloc(MWI_BUCKETS, mwi_sub_hash, mwi_sub_cmp);
 	RAII_VAR(struct ao2_container *, endpoints, ast_sorcery_retrieve_by_fields(
 				ast_sip_get_sorcery(), "endpoint", AST_RETRIEVE_FLAG_MULTIPLE | AST_RETRIEVE_FLAG_ALL, NULL),
 			ao2_cleanup);
 
-	ao2_callback(endpoints, OBJ_NODATA, create_mwi_subscriptions_for_endpoint, NULL);
+	if (!mwi_subscriptions) {
+		return;
+	}
+
+	ao2_callback(endpoints, OBJ_NODATA, create_mwi_subscriptions_for_endpoint, mwi_subscriptions);
+	ao2_global_obj_replace_unref(unsolicited_mwi, mwi_subscriptions);
 }
 
 static int load_module(void)
 {
 	if (ast_sip_register_subscription_handler(&mwi_handler)) {
 		return AST_MODULE_LOAD_DECLINE;
-	}
-	mwi_subscriptions = ao2_container_alloc(MWI_BUCKETS, mwi_sub_hash, mwi_sub_cmp);
-	if (!mwi_subscriptions) {
-		ast_sip_unregister_subscription_handler(&mwi_handler);
 	}
 	create_mwi_subscriptions();
 	return AST_MODULE_LOAD_SUCCESS;




More information about the svn-commits mailing list