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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Apr 12 17:46:25 CDT 2013


Author: mmichelson
Date: Fri Apr 12 17:46:22 2013
New Revision: 385596

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385596
Log:
Be sure to allocate subscriptions with proper roles defined.


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=385596&r1=385595&r2=385596
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_mwi.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_mwi.c Fri Apr 12 17:46:22 2013
@@ -133,7 +133,8 @@
 	ao2_cleanup(sub->stasis_subs);
 }
 
-static struct mwi_subscription *mwi_subscription_alloc(struct ast_sip_endpoint *endpoint, unsigned int is_solicited)
+static struct mwi_subscription *mwi_subscription_alloc(struct ast_sip_endpoint *endpoint,
+		enum ast_sip_subscription_role role, unsigned int is_solicited)
 {
 	struct mwi_subscription *sub;
 	const char *endpoint_id = ast_sorcery_object_get_id(endpoint);
@@ -147,12 +148,8 @@
 
 	/* Safe strcpy */
 	strcpy(sub->id, endpoint_id);
-	/* MWI is an interesting case because the NOTIFYs we send are
-	 * unsolicited. We get around the requirement of needing an
-	 * incoming SUBSCRIBE by pretending that we are the subscriber
-	 */
 	sub->sip_sub = ast_sip_create_subscription(&mwi_handler,
-			AST_SIP_SUBSCRIBER, endpoint, NULL);
+			role, endpoint, NULL);
 	if (!sub->sip_sub) {
 		ao2_cleanup(sub);
 		return NULL;
@@ -312,7 +309,7 @@
 		return NULL;
 	}
 
-	sub = mwi_subscription_alloc(endpoint, 1);
+	sub = mwi_subscription_alloc(endpoint, AST_SIP_NOTIFIER, 1);
 	if (!sub) {
 		return NULL;
 	}
@@ -431,8 +428,12 @@
 		return 0;
 	}
 
+	/* MWI is an interesting case because the NOTIFYs we send are
+	 * unsolicited. We get around the requirement of needing an
+	 * incoming SUBSCRIBE by pretending that we are the subscriber
+	 */
 	if (endpoint->aggregate_mwi) {
-		aggregate_sub = mwi_subscription_alloc(endpoint, 0);
+		aggregate_sub = mwi_subscription_alloc(endpoint, AST_SIP_SUBSCRIBER, 0);
 		if (!aggregate_sub) {
 			return 0;
 		}
@@ -440,7 +441,7 @@
 
 	mailboxes = ast_strdupa(endpoint->mailboxes);
 	while ((mailbox = strsep(&mailboxes, ","))) {
-		struct mwi_subscription *sub = aggregate_sub ?: mwi_subscription_alloc(endpoint, 0);
+		struct mwi_subscription *sub = aggregate_sub ?: mwi_subscription_alloc(endpoint, AST_SIP_SUBSCRIBER, 0);
 		RAII_VAR(struct mwi_stasis_subscription *, mwi_stasis_sub,
 				mwi_stasis_subscription_alloc(mailbox, sub), ao2_cleanup);
 		if (mwi_stasis_sub) {




More information about the svn-commits mailing list