[svn-commits] mmichelson: branch mmichelson/rls-rlmi r418260 - /team/mmichelson/rls-rlmi/res/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 9 19:58:32 CDT 2014


Author: mmichelson
Date: Wed Jul  9 19:58:27 2014
New Revision: 418260

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418260
Log:
Fix reference leaks of ast_sip_subscription and sip_subscription_tree.


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

Modified: team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c?view=diff&rev=418260&r1=418259&r2=418260
==============================================================================
--- team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-rlmi/res/res_pjsip_pubsub.c Wed Jul  9 19:58:27 2014
@@ -963,7 +963,7 @@
 {
 	struct ast_sip_subscription *sub = obj;
 
-	ast_debug(3, "Destroying SIP subscription\n");
+	ast_debug(3, "Destroying SIP subscription to resource %s\n", sub->resource);
 
 	ao2_cleanup(sub->datastores);
 }
@@ -1046,6 +1046,23 @@
 	return sub;
 }
 
+static void shutdown_subscriptions(struct ast_sip_subscription *sub)
+{
+	int i;
+
+	if (AST_VECTOR_SIZE(&sub->children) > 0) {
+		for (i = 0; i < AST_VECTOR_SIZE(&sub->children); ++i) {
+			shutdown_subscriptions(AST_VECTOR_GET(&sub->children, i));
+			ao2_cleanup(AST_VECTOR_GET(&sub->children, i));
+		}
+		return;
+	}
+
+	if (sub->handler->subscription_shutdown) {
+		sub->handler->subscription_shutdown(sub);
+	}
+}
+
 static void subscription_tree_destructor(void *obj)
 {
 	struct sip_subscription_tree *sub_tree = obj;
@@ -1056,6 +1073,9 @@
 	if (sub_tree->dlg) {
 		ast_sip_push_task_synchronous(NULL, subscription_remove_serializer, sub_tree);
 	}
+
+	shutdown_subscriptions(sub_tree->root);
+	ao2_cleanup(sub_tree->root);
 
 	ast_taskprocessor_unreference(sub_tree->serializer);
 	remove_subscription(sub_tree);
@@ -2631,22 +2651,6 @@
 	return PJ_FALSE;
 }
 
-static void shutdown_subscriptions(struct ast_sip_subscription *sub)
-{
-	int i;
-
-	if (AST_VECTOR_SIZE(&sub->children) > 0) {
-		for (i = 0; i < AST_VECTOR_SIZE(&sub->children); ++i) {
-			shutdown_subscriptions(AST_VECTOR_GET(&sub->children, i));
-		}
-		return;
-	}
-
-	if (sub->handler->subscription_shutdown) {
-		sub->handler->subscription_shutdown(sub);
-	}
-}
-
 static void pubsub_on_evsub_state(pjsip_evsub *evsub, pjsip_event *event)
 {
 	struct sip_subscription_tree *sub_tree;
@@ -2660,7 +2664,7 @@
 		return;
 	}
 
-	shutdown_subscriptions(sub_tree->root);
+	ao2_cleanup(sub_tree);
 
 	pjsip_evsub_set_mod_data(evsub, pubsub_module.id, NULL);
 }




More information about the svn-commits mailing list