[asterisk-commits] kmoore: branch 12 r413073 - in /branches/12/main: bridge.c bridge_basic.c

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


Author: kmoore
Date: Mon Apr 28 15:01:02 2014
New Revision: 413073

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413073
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.

Modified:
    branches/12/main/bridge.c
    branches/12/main/bridge_basic.c

Modified: branches/12/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bridge.c?view=diff&rev=413073&r1=413072&r2=413073
==============================================================================
--- branches/12/main/bridge.c (original)
+++ branches/12/main/bridge.c Mon Apr 28 15:01:02 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: branches/12/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bridge_basic.c?view=diff&rev=413073&r1=413072&r2=413073
==============================================================================
--- branches/12/main/bridge_basic.c (original)
+++ branches/12/main/bridge_basic.c Mon Apr 28 15:01:02 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