[asterisk-commits] jrose: branch jrose/bridge_projects r385498 - in /team/jrose/bridge_projects:...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 12 11:13:30 CDT 2013


Author: jrose
Date: Fri Apr 12 11:13:27 2013
New Revision: 385498

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385498
Log:
Fix a crash caused by bridge push/pull reference shenanigans

Modified:
    team/jrose/bridge_projects/bridges/bridge_builtin_features.c
    team/jrose/bridge_projects/include/asterisk/parking.h
    team/jrose/bridge_projects/main/parking.c
    team/jrose/bridge_projects/res/parking/parking_bridge.c

Modified: team/jrose/bridge_projects/bridges/bridge_builtin_features.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/bridges/bridge_builtin_features.c?view=diff&rev=385498&r1=385497&r2=385498
==============================================================================
--- team/jrose/bridge_projects/bridges/bridge_builtin_features.c (original)
+++ team/jrose/bridge_projects/bridges/bridge_builtin_features.c Fri Apr 12 11:13:27 2013
@@ -164,28 +164,6 @@
 	return "default";
 }
 
-/* XXX move this to parking.h */
-static struct ast_exten *get_parking_exten(const char *exten_str, struct ast_channel *chan, const char *context)
-{
-	struct ast_exten *exten;
-	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
-	const char *app_at_exten;
-
-	ast_debug(4, "Checking if %s@%s is a parking exten\n", exten_str, context);
-	exten = pbx_find_extension(chan, NULL, &q, context, exten_str, 1, NULL, NULL,
-		E_MATCH);
-	if (!exten) {
-		return NULL;
-	}
-
-	app_at_exten = ast_get_extension_app(exten);
-	if (!app_at_exten || strcasecmp(PARK_APPLICATION, app_at_exten)) {
-		return NULL;
-	}
-
-	return exten;
-}
-
 /*! \brief Internal built in feature for blind transfers */
 static int feature_blind_transfer(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 {
@@ -207,7 +185,7 @@
 	}
 
 	/* Parking blind transfer override - phase this out for something more general purpose in the future. */
-	park_exten = get_parking_exten(exten, bridge_channel->chan, context);
+	park_exten = ast_get_parking_exten(exten, bridge_channel->chan, context);
 	if (park_exten) {
 		/* We are transfering the transferee to a parking lot. */
 		if (ast_park_blind_xfer(bridge, bridge_channel, ast_get_extension_app_data(park_exten))) {

Modified: team/jrose/bridge_projects/include/asterisk/parking.h
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/include/asterisk/parking.h?view=diff&rev=385498&r1=385497&r2=385498
==============================================================================
--- team/jrose/bridge_projects/include/asterisk/parking.h (original)
+++ team/jrose/bridge_projects/include/asterisk/parking.h Fri Apr 12 11:13:27 2013
@@ -131,3 +131,16 @@
  */
 int ast_park_blind_xfer(struct ast_bridge *bridge, struct ast_bridge_channel *parker,
 		const char *app_data);
+
+/*!
+ * \brief Determines whether a certain extension is a park application extension or not.
+ * \since 12
+ *
+ * \param exten_str string representation of the extension sought
+ * \param chan channel the extension is sought for
+ * \param context context the extension is sought from
+ *
+ * \retval pointer to the extension if the extension is a park extension
+ * \retval NULL if the extension was not a park extension
+ */
+struct ast_exten *ast_get_parking_exten(const char *exten_str, struct ast_channel *chan, const char *context);

Modified: team/jrose/bridge_projects/main/parking.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/main/parking.c?view=diff&rev=385498&r1=385497&r2=385498
==============================================================================
--- team/jrose/bridge_projects/main/parking.c (original)
+++ team/jrose/bridge_projects/main/parking.c Fri Apr 12 11:13:27 2013
@@ -144,3 +144,24 @@
 
 	return -1;
 }
+
+struct ast_exten *ast_get_parking_exten(const char *exten_str, struct ast_channel *chan, const char *context)
+{
+	struct ast_exten *exten;
+	struct pbx_find_info q = { .stacklen = 0 }; /* the rest is reset in pbx_find_extension */
+	const char *app_at_exten;
+
+	ast_debug(4, "Checking if %s@%s is a parking exten\n", exten_str, context);
+	exten = pbx_find_extension(chan, NULL, &q, context, exten_str, 1, NULL, NULL,
+		E_MATCH);
+	if (!exten) {
+		return NULL;
+	}
+
+	app_at_exten = ast_get_extension_app(exten);
+	if (!app_at_exten || strcasecmp(PARK_APPLICATION, app_at_exten)) {
+		return NULL;
+	}
+
+	return exten;
+}

Modified: team/jrose/bridge_projects/res/parking/parking_bridge.c
URL: http://svnview.digium.com/svn/asterisk/team/jrose/bridge_projects/res/parking/parking_bridge.c?view=diff&rev=385498&r1=385497&r2=385498
==============================================================================
--- team/jrose/bridge_projects/res/parking/parking_bridge.c (original)
+++ team/jrose/bridge_projects/res/parking/parking_bridge.c Fri Apr 12 11:13:27 2013
@@ -99,18 +99,17 @@
 			return -1;
 		}
 
-		/* Give the swap channel's parked user to the incoming channel */
+		/* Give the swap channel's parked user reference to the incoming channel */
 		pu->chan = bridge_channel->chan;
 		bridge_channel->bridge_pvt = pu;
 		swap->bridge_pvt = NULL;
 
 		/* XXX Add a parked call swap message type to relay information about parked channel swaps */
 
-		ao2_ref(pu, -1);
 		return 0;
 	}
 
-	/* We should already have a parked user set for the channel when we push */
+	/* We should already have a parked user set for the channel when we push. Take a reference to it. We'll keep this. */
 	for (iter = ao2_iterator_init(self->lot->parked_user_list, 0); (pu = ao2_iterator_next(&iter)); ao2_ref(pu, -1)) {
 		if (bridge_channel->chan != pu->chan) {
 			continue;
@@ -136,7 +135,6 @@
 	/* Generate ParkedCall Stasis Message */
 	publish_parked_call(pu, PARKED_CALL);
 
-	ao2_ref(pu, -1);
 	return 0;
 }
 
@@ -154,9 +152,13 @@
  */
 static void bridge_parking_pull(struct ast_bridge_parking *self, struct ast_bridge_channel *bridge_channel)
 {
-	struct parked_user *pu = bridge_channel->bridge_pvt;
+	RAII_VAR(struct parked_user *, pu, NULL, ao2_cleanup);
 	struct ast_bridge_features *features = bridge_channel->features;
 	ast_bridge_base_v_table.pull(&self->base, bridge_channel);
+
+	/* Take over the bridge channel's pu reference. It will be released when we are done. */
+	pu = bridge_channel->bridge_pvt;
+	bridge_channel->bridge_pvt = NULL;
 
 	/* This should only happen if the exiting channel was swapped out */
 	if (!pu) {




More information about the asterisk-commits mailing list