[svn-commits] mmichelson: branch mmichelson/rls-notify r420264 - /team/mmichelson/rls-notif...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 6 16:58:50 CDT 2014


Author: mmichelson
Date: Wed Aug  6 16:58:46 2014
New Revision: 420264

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420264
Log:
Address review feedback.

Mainly fixing memory leaks.


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

Modified: team/mmichelson/rls-notify/res/res_pjsip_exten_state.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-notify/res/res_pjsip_exten_state.c?view=diff&rev=420264&r1=420263&r2=420264
==============================================================================
--- team/mmichelson/rls-notify/res/res_pjsip_exten_state.c (original)
+++ team/mmichelson/rls-notify/res/res_pjsip_exten_state.c Wed Aug  6 16:58:46 2014
@@ -200,12 +200,8 @@
 	task_data->exten_state_data.presence_subtype = ast_strdup(info->presence_subtype);
 	task_data->exten_state_data.presence_message = ast_strdup(info->presence_message);
 	task_data->exten_state_data.user_agent = ast_strdup(exten_state_sub->user_agent);
-	task_data->exten_state_data.device_state_info = info->device_state_info;
+	task_data->exten_state_data.device_state_info = ao2_bump(info->device_state_info);
 	task_data->exten_state_data.sub = exten_state_sub->sip_sub;
-
-	if (task_data->exten_state_data.device_state_info) {
-		ao2_ref(task_data->exten_state_data.device_state_info, +1);
-	}
 
 	ast_sip_subscription_get_local_uri(exten_state_sub->sip_sub,
 			task_data->exten_state_data.local, sizeof(task_data->exten_state_data.local));
@@ -396,7 +392,6 @@
 		struct exten_state_subscription *exten_state_sub)
 {
 	struct ast_sip_exten_state_data *exten_state_data;
-	struct ao2_container *info;
 	char *subtype = NULL;
 	char *message = NULL;
 
@@ -420,8 +415,10 @@
 			sizeof(exten_state_data->remote));
 	exten_state_data->sub = sip_sub;
 
-	if ((exten_state_data->exten_state = ast_extension_state_extended(
-		     NULL, exten_state_sub->context, exten_state_sub->exten, &info)) < 0) {
+	exten_state_data->exten_state = ast_extension_state_extended(
+			NULL, exten_state_sub->context, exten_state_sub->exten,
+			&exten_state_data->device_state_info);
+	if (exten_state_data->exten_state < 0) {
 		ao2_cleanup(exten_state_data);
 		return NULL;
 	}
@@ -433,7 +430,6 @@
 		return NULL;
 	}
 
-	exten_state_data->device_state_info = info;
 	return exten_state_data;
 }
 

Modified: team/mmichelson/rls-notify/res/res_pjsip_mwi.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-notify/res/res_pjsip_mwi.c?view=diff&rev=420264&r1=420263&r2=420264
==============================================================================
--- team/mmichelson/rls-notify/res/res_pjsip_mwi.c (original)
+++ team/mmichelson/rls-notify/res/res_pjsip_mwi.c Wed Aug  6 16:58:46 2014
@@ -47,6 +47,8 @@
 
 #define MWI_TYPE "application"
 #define MWI_SUBTYPE "simple-message-summary"
+
+#define MWI_DATASTORE "MWI datastore"
 
 static void mwi_subscription_shutdown(struct ast_sip_subscription *sub);
 static void mwi_to_ami(struct ast_sip_subscription *sub, struct ast_str **buf);
@@ -458,7 +460,7 @@
 {
 	struct mwi_subscription *mwi_sub;
 	RAII_VAR(struct ast_datastore *, mwi_datastore,
-			ast_sip_subscription_get_datastore(sub, "MWI datastore"), ao2_cleanup);
+			ast_sip_subscription_get_datastore(sub, MWI_DATASTORE), ao2_cleanup);
 
 	if (!mwi_datastore) {
 		return;
@@ -474,7 +476,7 @@
 {
 	RAII_VAR(struct ast_datastore *, mwi_datastore, NULL, ao2_cleanup);
 
-	mwi_datastore = ast_sip_subscription_alloc_datastore(&mwi_ds_info, "MWI datastore");
+	mwi_datastore = ast_sip_subscription_alloc_datastore(&mwi_ds_info, MWI_DATASTORE);
 	if (!mwi_datastore) {
 		return -1;
 	}
@@ -698,7 +700,6 @@
 	ao2_cleanup(sub);
 	ao2_cleanup(endpoint);
 	return 0;
-
 }
 
 static void *mwi_get_notify_data(struct ast_sip_subscription *sub)
@@ -707,7 +708,7 @@
 	struct mwi_subscription *mwi_sub;
 	struct ast_datastore *mwi_datastore;
 
-	mwi_datastore = ast_sip_subscription_get_datastore(sub, "MWI datastore");
+	mwi_datastore = ast_sip_subscription_get_datastore(sub, MWI_DATASTORE);
 	if (!mwi_datastore) {
 		return NULL;
 	}
@@ -748,7 +749,7 @@
 {
 	struct mwi_subscription *mwi_sub;
 	RAII_VAR(struct ast_datastore *, mwi_datastore,
-			ast_sip_subscription_get_datastore(sub, "MWI datastore"), ao2_cleanup);
+			ast_sip_subscription_get_datastore(sub, MWI_DATASTORE), ao2_cleanup);
 
 	if (!mwi_datastore) {
 		return;

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=420264&r1=420263&r2=420264
==============================================================================
--- team/mmichelson/rls-notify/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-notify/res/res_pjsip_pubsub.c Wed Aug  6 16:58:46 2014
@@ -1040,7 +1040,10 @@
 			continue;
 		}
 
-		AST_VECTOR_APPEND(&sub->children, child);
+		if (AST_VECTOR_APPEND(&sub->children, child)) {
+			ast_debug(1, "Child subscription to resource %s could not be appended\n",
+					child_node->resource);
+		}
 	}
 
 	return sub;
@@ -1050,6 +1053,7 @@
 {
 	struct sip_subscription_tree *sub_tree = obj;
 
+	remove_subscription(sub_tree);
 	subscription_persistence_remove(sub_tree);
 	ao2_cleanup(sub_tree->endpoint);
 
@@ -1058,7 +1062,6 @@
 	}
 
 	ast_taskprocessor_unreference(sub_tree->serializer);
-	remove_subscription(sub_tree);
 }
 
 static void subscription_setup_dialog(struct sip_subscription_tree *sub_tree, pjsip_dialog *dlg)
@@ -1362,7 +1365,7 @@
 struct ast_sip_subscription *ast_sip_create_subscription(const struct ast_sip_subscription_handler *handler,
 		struct ast_sip_endpoint *endpoint, const char *resource)
 {
-	struct ast_sip_subscription *sub = ao2_alloc(sizeof(*sub) + strlen(resource) + 1, subscription_destructor);
+	struct ast_sip_subscription *sub;
 	pjsip_dialog *dlg;
 	struct ast_sip_contact *contact;
 	pj_str_t event;
@@ -1385,7 +1388,7 @@
 	if (!contact || ast_strlen_zero(contact->uri)) {
 		ast_log(LOG_WARNING, "No contacts configured for endpoint %s. Unable to create SIP subsription\n",
 				ast_sorcery_object_get_id(endpoint));
-		ao2_ref(sub, -1);
+		ao2_ref(sub_tree, -1);
 		ao2_cleanup(contact);
 		return NULL;
 	}
@@ -1394,15 +1397,13 @@
 	ao2_cleanup(contact);
 	if (!dlg) {
 		ast_log(LOG_WARNING, "Unable to create dialog for SIP subscription\n");
-		ao2_ref(sub, -1);
+		ao2_ref(sub_tree, -1);
 		return NULL;
 	}
 
 	pj_cstr(&event, handler->event_name);
 	pjsip_evsub_create_uac(dlg, &pubsub_cb, &event, 0, &sub_tree->evsub);
 	subscription_setup_dialog(sub_tree, dlg);
-
-	add_subscription(sub_tree);
 
 	evsub = sub_tree->evsub;
 
@@ -1414,6 +1415,7 @@
 		 * need to decrease the reference count of sub here.
 		 */
 		pjsip_evsub_terminate(evsub, PJ_TRUE);
+		ao2_ref(sub_tree, -1);
 		return NULL;
 	}
 
@@ -1487,7 +1489,7 @@
 		.type = ast_sip_subscription_get_body_type(sub_tree->root),
 		.subtype = ast_sip_subscription_get_body_subtype(sub_tree->root),
 	};
-	RAII_VAR(struct ast_str *, body_text, ast_str_create(64), ast_free_ptr);
+	RAII_VAR(struct ast_str *, body_text, ast_str_create(64), ast_free);
 
 	if (!body_text) {
 		return -1;




More information about the svn-commits mailing list