[asterisk-commits] irroot: branch irroot/distrotech-customers-trunk r320500 - /team/irroot/distr...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 23 08:44:00 CDT 2011


Author: irroot
Date: Mon May 23 08:43:49 2011
New Revision: 320500

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=320500
Log:
Deadlock Avoidance ast_channel_cmp_cb

Modified:
    team/irroot/distrotech-customers-trunk/main/channel.c

Modified: team/irroot/distrotech-customers-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-trunk/main/channel.c?view=diff&rev=320500&r1=320499&r2=320500
==============================================================================
--- team/irroot/distrotech-customers-trunk/main/channel.c (original)
+++ team/irroot/distrotech-customers-trunk/main/channel.c Mon May 23 08:43:49 2011
@@ -1658,13 +1658,21 @@
 	struct ast_channel *chan = obj, *cmp_args = arg;
 	size_t name_len;
 	int ret = CMP_MATCH;
+	int locktry = 10;
 
 	/* This is sort of a hack.  Basically, we're using an arbitrary field
 	 * in ast_channel to pass the name_len for a prefix match.  If this
 	 * gets changed, then the uses of ao2_find() must be changed, too. */
 	name_len = cmp_args->rings;
 
-	ast_channel_lock(chan);
+	/*Deadlock avoidance*/
+	while (ast_channel_trylock(chan)) {
+		if (locktry++ > 10) {
+			ast_debug(1, "Deadlock avoided for ast_channel_cmp_cb '%s'\n", chan->name);
+			return 0;
+		}
+		usleep(1);
+	}
 
 	if (!ast_strlen_zero(cmp_args->name)) { /* match by name */
 		if ((!name_len && strcasecmp(chan->name, cmp_args->name)) ||




More information about the asterisk-commits mailing list