[asterisk-commits] mmichelson: branch mmichelson/rls-notify r418164 - /team/mmichelson/rls-notif...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 7 18:48:14 CDT 2014


Author: mmichelson
Date: Mon Jul  7 18:48:12 2014
New Revision: 418164

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418164
Log:
Get rid of a XXX comment about needing to allocate a subscription tree.


Modified:
    team/mmichelson/rls-notify/res/res_pjsip_pubsub.c

Modified: team/mmichelson/rls-notify/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-notify/res/res_pjsip_pubsub.c?view=diff&rev=418164&r1=418163&r2=418164
==============================================================================
--- team/mmichelson/rls-notify/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-notify/res/res_pjsip_pubsub.c Mon Jul  7 18:48:12 2014
@@ -1044,6 +1044,27 @@
 	pjsip_evsub_set_mod_data(sub_tree->evsub, pubsub_module.id, sub_tree);
 }
 
+static struct sip_subscription_tree *allocate_subscription_tree(struct ast_sip_endpoint *endpoint)
+{
+	struct sip_subscription_tree *sub_tree;
+
+	sub_tree = ao2_alloc(sizeof *sub_tree, subscription_tree_destructor);
+	if (!sub_tree) {
+		return NULL;
+	}
+
+	sub_tree->serializer = ast_sip_create_serializer();
+	if (!sub_tree->serializer) {
+		ao2_ref(sub_tree, -1);
+		return NULL;
+	}
+
+	sub_tree->endpoint = ao2_bump(endpoint);
+
+	add_subscription(sub_tree);
+	return sub_tree;
+}
+
 /*!
  * \brief Create a subscription tree based on a resource tree.
  *
@@ -1071,14 +1092,8 @@
 	pjsip_dialog *dlg;
 	struct subscription_persistence *persistence;
 
-	sub_tree = ao2_alloc(sizeof *sub_tree, subscription_tree_destructor);
+	sub_tree = allocate_subscription_tree(endpoint);
 	if (!sub_tree) {
-		return NULL;
-	}
-
-	sub_tree->serializer = ast_sip_create_serializer();
-	if (!sub_tree->serializer) {
-		ao2_ref(sub_tree, -1);
 		return NULL;
 	}
 
@@ -1107,15 +1122,12 @@
 	ast_sip_mod_data_set(dlg->pool, dlg->mod_data, pubsub_module.id, MOD_DATA_MSG,
 			pjsip_msg_clone(dlg->pool, rdata->msg_info.msg));
 
-	sub_tree->endpoint = ao2_bump(endpoint);
 	sub_tree->notification_batch_interval = tree->notification_batch_interval;
 
 	sub_tree->root = create_virtual_subscriptions(handler, resource, generator, sub_tree, tree->root);
 	if (AST_VECTOR_SIZE(&sub_tree->root->children) > 0) {
 		sub_tree->is_list = 1;
 	}
-
-	add_subscription(sub_tree);
 
 	return sub_tree;
 }
@@ -1329,9 +1341,14 @@
 	pjsip_evsub *evsub;
 	struct sip_subscription_tree *sub_tree = NULL;
 
-	/* XXX Need allocation function for the sub_tree here */
+	sub_tree = allocate_subscription_tree(endpoint);
+	if (!sub_tree) {
+		return NULL;
+	}
+
 	sub = allocate_subscription(handler, resource, sub_tree);
 	if (!sub) {
+		ao2_cleanup(sub_tree);
 		return NULL;
 	}
 




More information about the asterisk-commits mailing list