[asterisk-commits] kmoore: trunk r413074 - in /trunk: ./ main/bridge.c main/bridge_basic.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 28 15:07:43 CDT 2014


Author: kmoore
Date: Mon Apr 28 15:07:37 2014
New Revision: 413074

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413074
Log:
Bridging: Don't lock NULL bridges

When bridge locking was added for bridge snapshot creation, some
locations where bridge locking was added were not guaranteed to
actually have a bridge and locking NULL AO2 objects tends to cause
segfaults. This ensures that NULL bridges aren't locked.
........

Merged revisions 413073 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/main/bridge.c
    trunk/main/bridge_basic.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge.c?view=diff&rev=413074&r1=413073&r2=413074
==============================================================================
--- trunk/main/bridge.c (original)
+++ trunk/main/bridge.c Mon Apr 28 15:07:37 2014
@@ -4072,9 +4072,13 @@
 	struct ast_bridge_channel_pair pair;
 	pair.channel = transferer;
 	pair.bridge = bridge;
-	ast_bridge_lock(bridge);
+	if (bridge) {
+		ast_bridge_lock(bridge);
+	}
 	ast_bridge_publish_blind_transfer(is_external, result, &pair, context, exten);
-	ast_bridge_unlock(bridge);
+	if (bridge) {
+		ast_bridge_unlock(bridge);
+	}
 }
 
 enum ast_transfer_result ast_bridge_transfer_blind(int is_external,

Modified: trunk/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge_basic.c?view=diff&rev=413074&r1=413073&r2=413074
==============================================================================
--- trunk/main/bridge_basic.c (original)
+++ trunk/main/bridge_basic.c Mon Apr 28 15:07:37 2014
@@ -1534,11 +1534,23 @@
 		.bridge = props->target_bridge,
 	};
 
-	ast_bridge_lock_both(transferee.bridge, transfer_target.bridge);
+	if (transferee.bridge && transfer_target.bridge) {
+		ast_bridge_lock_both(transferee.bridge, transfer_target.bridge);
+	} else if (transferee.bridge) {
+		ast_bridge_lock(transferee.bridge);
+	} else if (transfer_target.bridge) {
+		ast_bridge_lock(transfer_target.bridge);
+	}
+
 	ast_bridge_publish_attended_transfer_bridge_merge(0, AST_BRIDGE_TRANSFER_SUCCESS,
 			&transferee, &transfer_target, props->transferee_bridge);
-	ast_bridge_unlock(transferee.bridge);
-	ast_bridge_unlock(transfer_target.bridge);
+
+	if (transferee.bridge) {
+		ast_bridge_unlock(transferee.bridge);
+	}
+	if (transfer_target.bridge) {
+		ast_bridge_unlock(transfer_target.bridge);
+	}
 }
 
 /*!
@@ -1559,11 +1571,23 @@
 		.bridge = props->transferee_bridge,
 	};
 
-	ast_bridge_lock_both(transferee.bridge, transfer_target.bridge);
+	if (transferee.bridge && transfer_target.bridge) {
+		ast_bridge_lock_both(transferee.bridge, transfer_target.bridge);
+	} else if (transferee.bridge) {
+		ast_bridge_lock(transferee.bridge);
+	} else if (transfer_target.bridge) {
+		ast_bridge_lock(transfer_target.bridge);
+	}
+
 	ast_bridge_publish_attended_transfer_threeway(0, AST_BRIDGE_TRANSFER_SUCCESS,
 			&transferee, &transfer_target, &threeway);
-	ast_bridge_unlock(transferee.bridge);
-	ast_bridge_unlock(transfer_target.bridge);
+
+	if (transferee.bridge) {
+		ast_bridge_unlock(transferee.bridge);
+	}
+	if (transfer_target.bridge) {
+		ast_bridge_unlock(transfer_target.bridge);
+	}
 }
 
 /*!
@@ -1580,11 +1604,23 @@
 		.bridge = props->target_bridge,
 	};
 
-	ast_bridge_lock_both(transferee.bridge, transfer_target.bridge);
+	if (transferee.bridge && transfer_target.bridge) {
+		ast_bridge_lock_both(transferee.bridge, transfer_target.bridge);
+	} else if (transferee.bridge) {
+		ast_bridge_lock(transferee.bridge);
+	} else if (transfer_target.bridge) {
+		ast_bridge_lock(transfer_target.bridge);
+	}
+
 	ast_bridge_publish_attended_transfer_fail(0, AST_BRIDGE_TRANSFER_FAIL,
 			&transferee, &transfer_target);
-	ast_bridge_unlock(transferee.bridge);
-	ast_bridge_unlock(transfer_target.bridge);
+
+	if (transferee.bridge) {
+		ast_bridge_unlock(transferee.bridge);
+	}
+	if (transfer_target.bridge) {
+		ast_bridge_unlock(transfer_target.bridge);
+	}
 }
 
 /*!




More information about the asterisk-commits mailing list