[asterisk-commits] rmudgett: trunk r392166 - in /trunk: include/asterisk/bridging.h main/bridging.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 18 14:31:32 CDT 2013


Author: rmudgett
Date: Tue Jun 18 14:31:31 2013
New Revision: 392166

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392166
Log:
Bridging: Fix crash on destruction of a partially constructed bridge.

* Promoted some bridge construction debug messages to warnings.

Modified:
    trunk/include/asterisk/bridging.h
    trunk/main/bridging.c

Modified: trunk/include/asterisk/bridging.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/bridging.h?view=diff&rev=392166&r1=392165&r2=392166
==============================================================================
--- trunk/include/asterisk/bridging.h (original)
+++ trunk/include/asterisk/bridging.h Tue Jun 18 14:31:31 2013
@@ -436,6 +436,8 @@
 	unsigned int reconfigured:1;
 	/*! TRUE if the bridge has been dissolved.  Any channel that now tries to join is immediately ejected. */
 	unsigned int dissolved:1;
+	/*! TRUE if the bridge construction was completed. */
+	unsigned int construction_completed:1;
 };
 
 /*!

Modified: trunk/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridging.c?view=diff&rev=392166&r1=392165&r2=392166
==============================================================================
--- trunk/main/bridging.c (original)
+++ trunk/main/bridging.c Tue Jun 18 14:31:31 2013
@@ -1382,6 +1382,7 @@
 static struct stasis_message *create_bridge_snapshot_message(struct ast_bridge *bridge)
 {
 	RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup);
+
 	snapshot = ast_bridge_snapshot_create(bridge);
 	if (!snapshot) {
 		return NULL;
@@ -1393,17 +1394,21 @@
 static void destroy_bridge(void *obj)
 {
 	struct ast_bridge *bridge = obj;
-	RAII_VAR(struct stasis_message *, clear_msg, NULL, ao2_cleanup);
 
 	ast_debug(1, "Bridge %s: actually destroying %s bridge, nobody wants it anymore\n",
 		bridge->uniqueid, bridge->v_table->name);
 
-	clear_msg = create_bridge_snapshot_message(bridge);
-	if (clear_msg) {
-		RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
-		msg = stasis_cache_clear_create(clear_msg);
-		if (msg) {
-			stasis_publish(ast_bridge_topic(bridge), msg);
+	if (bridge->construction_completed) {
+		RAII_VAR(struct stasis_message *, clear_msg, NULL, ao2_cleanup);
+
+		clear_msg = create_bridge_snapshot_message(bridge);
+		if (clear_msg) {
+			RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
+
+			msg = stasis_cache_clear_create(clear_msg);
+			if (msg) {
+				stasis_publish(ast_bridge_topic(bridge), msg);
+			}
 		}
 	}
 
@@ -1447,6 +1452,7 @@
 struct ast_bridge *ast_bridge_register(struct ast_bridge *bridge)
 {
 	if (bridge) {
+		bridge->construction_completed = 1;
 		ast_bridge_publish_state(bridge);
 		if (!ao2_link(bridges, bridge)) {
 			ast_bridge_destroy(bridge);
@@ -1495,8 +1501,8 @@
 	/* Use our helper function to find the "best" bridge technology. */
 	self->technology = find_best_technology(capabilities, self);
 	if (!self->technology) {
-		ast_debug(1, "Bridge %s: Could not create.  No technology available to support it.\n",
-			self->uniqueid);
+		ast_log(LOG_WARNING, "Bridge %s: Could not create class %s.  No technology to support it.\n",
+			self->uniqueid, self->v_table->name);
 		ao2_ref(self, -1);
 		return NULL;
 	}
@@ -1505,7 +1511,7 @@
 	ast_debug(1, "Bridge %s: calling %s technology constructor\n",
 		self->uniqueid, self->technology->name);
 	if (self->technology->create && self->technology->create(self)) {
-		ast_debug(1, "Bridge %s: failed to setup %s technology\n",
+		ast_log(LOG_WARNING, "Bridge %s: failed to setup bridge technology %s\n",
 			self->uniqueid, self->technology->name);
 		ao2_ref(self, -1);
 		return NULL;
@@ -1513,7 +1519,7 @@
 	ast_debug(1, "Bridge %s: calling %s technology start\n",
 		self->uniqueid, self->technology->name);
 	if (self->technology->start && self->technology->start(self)) {
-		ast_debug(1, "Bridge %s: failed to start %s technology\n",
+		ast_log(LOG_WARNING, "Bridge %s: failed to start bridge technology %s\n",
 			self->uniqueid, self->technology->name);
 		ao2_ref(self, -1);
 		return NULL;




More information about the asterisk-commits mailing list