[asterisk-addons-commits] mnicholson: branch mnicholson/chan-mobile-refactor r811 - /team/mnicholson/ch...

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Tue Mar 17 17:43:07 CDT 2009


Author: mnicholson
Date: Tue Mar 17 17:43:04 2009
New Revision: 811

URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=811
Log:
added deadlock avoidance to chan_mobile ast_hangup calls

Modified:
    team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c

Modified: team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c
URL: http://svn.digium.com/svn-view/asterisk-addons/team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c?view=diff&rev=811&r1=810&r2=811
==============================================================================
--- team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c (original)
+++ team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c Tue Mar 17 17:43:04 2009
@@ -220,6 +220,7 @@
 
 static int mbl_queue_control(struct mbl_pvt *pvt, enum ast_control_frame_type control);
 static int mbl_queue_hangup(struct mbl_pvt *pvt);
+static int mbl_ast_hangup(struct mbl_pvt *pvt);
 
 static int rfcomm_connect(bdaddr_t src, bdaddr_t dst, int remote_channel);
 static int rfcomm_write(int rsock, char *buf);
@@ -1219,6 +1220,25 @@
 			break;
 	}
 	return 0;
+}
+
+static int mbl_ast_hangup(struct mbl_pvt *pvt)
+{
+	int res = 0;
+	for (;;) {
+		if (pvt->owner) {
+			if (ast_channel_trylock(pvt->owner)) {
+				DEADLOCK_AVOIDANCE(&pvt->lock);
+			} else {
+				res = ast_hangup(pvt->owner);
+				/* no need to unlock, ast_hangup() frees the
+				 * channel */
+				break;
+			}
+		} else
+			break;
+	}
+	return res;
 }
 
 /*
@@ -3104,7 +3124,7 @@
 
 		if (ast_pbx_start(chan)) {
 			ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming call\n", pvt->id);
-			ast_hangup(chan);
+			mbl_ast_hangup(pvt);
 			return -1;
 		}
 
@@ -3183,7 +3203,7 @@
 
 	if (ast_pbx_start(chan)) {
 		ast_log(LOG_ERROR, "[%s] unable to start pbx on incoming sms\n", pvt->id);
-		ast_hangup(chan);
+		mbl_ast_hangup(pvt);
 	}
 
 	return 0;




More information about the asterisk-addons-commits mailing list