[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r320499 - /team/irroot/distrot...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon May 23 08:40:21 CDT 2011
Author: irroot
Date: Mon May 23 08:40:09 2011
New Revision: 320499
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=320499
Log:
Deadlock Avoidance ast_channel_cmp_cb
Modified:
team/irroot/distrotech-customers-1.8/main/channel.c
Modified: team/irroot/distrotech-customers-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/main/channel.c?view=diff&rev=320499&r1=320498&r2=320499
==============================================================================
--- team/irroot/distrotech-customers-1.8/main/channel.c (original)
+++ team/irroot/distrotech-customers-1.8/main/channel.c Mon May 23 08:40:09 2011
@@ -1632,13 +1632,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